首页 > 代码库 > 用于部署war并重启Tomcat的脚本
用于部署war并重启Tomcat的脚本
只需要定义两个变量, 一个是目标tomcat实例的目录, 另一个是war包的名称
# Please define the absolute path of tomcat instanceTHIS_TC_INSTANCE=‘/home/tomcat/tomcat8_jdk8_1‘THIS_APP_MODULE=‘throne-commons‘df -hecho ‘‘pid=`ps -ef|grep ${THIS_TC_INSTANCE}|grep -v ‘grep‘|grep ‘java‘|awk ‘{print $2}‘`if [ -z $pid ] ; then echo ‘Tomcat ‘${THIS_TC_INSTANCE}‘ is not running‘else echo ‘Shutting down Tomcat at ‘${THIS_TC_INSTANCE} ${THIS_TC_INSTANCE}/bin/shutdown.sh sleep 5fipid=`ps -ef|grep ${THIS_TC_INSTANCE}|grep -v ‘grep‘|grep ‘java‘|awk ‘{print $2}‘`if [ -z $pid ] ; then echo ‘Tomcat ‘${THIS_TC_INSTANCE}‘ has been shut down‘else echo ‘Tomcat ‘${THIS_TC_INSTANCE}‘ didnot exit normally, now killing the PID:‘${pid} ps -ef|grep ${THIS_TC_INSTANCE}|grep -v ‘grep‘|grep ‘java‘|awk ‘{print $2}‘|xargs kill -s 9fiecho ‘‘echo ‘Removing old deployments‘rm -f ${THIS_TC_INSTANCE}/webapps/${THIS_APP_MODULE}.warrm -rf ${THIS_TC_INSTANCE}/webapps/${THIS_APP_MODULE}echo ‘Copying new deployments‘echo ‘‘cp -f /home/tomcat/builds/${THIS_APP_MODULE}.war ${THIS_TC_INSTANCE}/webapps/echo ‘Startup tomcat‘${THIS_TC_INSTANCE}/bin/startup.sh
对应的Jenkins Pipeline配置
node { // Mark the code checkout ‘stage‘.... stage ‘Checkout‘ sh "mkdir -p throne-commons-impl" dir(‘throne-commons-impl‘) { git branch: ‘master‘, credentialsId: ‘859dde85-5e0c-4ab3-8fd1-d31c96d4cae4‘, url: ‘git@192.168.255.109:yhc/throne-commons-impl.git‘ } env.JAVA_HOME="${tool ‘jdk1.8.0_101‘}" sh ‘$JAVA_HOME/bin/java -version‘ def mvnHome = tool ‘apache-maven-3.3.9‘ stage ‘Build‘ dir(‘throne-commons-impl‘) { sh "${mvnHome}/bin/mvn -s /home/tomcat/files/settings.xml clean package -Dmaven.test.skip=true -Pthrone_qa -e" } stage ‘Publish‘ sshagent([‘594d69cf-fd5e-45ea-8ab0-c94db218017a‘]) { sh ‘ssh -p 22 tomcat@192.168.255.107 \‘df -h\‘‘ sh ‘scp throne-commons-impl/target/throne-commons.war tomcat@192.168.255.107:/home/tomcat/builds/‘ sh ‘ssh -p 22 tomcat@192.168.255.107 \‘/home/tomcat/scripts/deploy_t8_j8_1_commons.sh\‘‘ }}
用于部署war并重启Tomcat的脚本
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。