UBUNTU+TOMCAT, multi-environment, automated deployment scripts, Git+maven+tomcat+ubuntu

Source: Internet
Author: User
Tags server memory

Projectname= "", #默认tomcat目录名称, can be changed to their own tomcat name according to their own needs, tomcatname= "tomcat7_8080", #通过直接杀进程停止tomcat, to prevent hot deployment caused insufficient server memory, To make the client access uninterrupted, you can load echo "Stop $tomcatname" Ps-ef|grep $tomcatName |grep-v grep|cut-c 9-15|xargs kill-9;echo "stop successfully "; #切换到代码目录cd/opt/code/your_project-git;echo" Cd/opt/code/your_project-git "; #打印当前git代码分支echo" Current branch: "Git Symbolic-ref--short-q Head;echo "Pull the latest code"; #更新代码git Pull;echo "pull complete"; echo "****************************************** The "; echo" Environment variable is: $ "; #多环境情况下, the deployment environment can be passed through variables, such as test 1 environment, Test 2 Environment echo" maven compilation start "; mvn Clean Install-p$1;echo "maven compile complete"; #循环部署项目, if different projects have different tomcatname, re-specify tomcatnamefor arg in "[email " directly in the corresponding if    Protected] "do projectname=" ";    Contextname= $arg;    If ["$arg" = "app"];    Then projectname= "App";    elif ["$arg" = "merchant"];    Then projectname= "Merchant";    elif ["$arg" = "Mgmt"];        Then projectname= "Mgmt";    Tomcatname= "tomcat7_8080";    elif ["$arg" = "job"];  Then      Projectname= "Job";    fi if ["$projectName"! = ""];        Then #删除tomcat中对应的项目 echo "Delete/usr/local/tomcat/$tomcatName/webapps/$contextName *";        rm-rf/usr/local/tomcat/$tomcatName/webapps/$contextName *;        echo "Delete Complete";     echo "********************************************************************************"; #复制通过maven打包完成的war到tomcat目录 echo "Copy mb-$projectName-web/target/$projectName. War to/usr/local/tomcat/$tomcatName/w        ebapps/$contextName $lang.war ";        CP mb-$projectName-web/target/$projectName. war/usr/local/tomcat/$tomcatName/webapps/$contextName $lang.war;        echo "Copy succeeded";    echo "********************************************************************************"; fidone# start Tomcat, if each project corresponds to a different tomcat, place the start command behind the Copy Item command in the corresponding loop and echo "Start $tomcatname"; sh/usr/local/tomcat/$tomcatName/ Bin/startup.sh;echo "Start Success";

  

UBUNTU+TOMCAT, multi-environment, automated deployment scripts, Git+maven+tomcat+ubuntu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.