maven项目自动git打包发布重启Tomcat

废话不多说直接上脚本,也可以直接下载原脚本文件

#!/bin/bash
#Time
log_time=`date +[%Y-%m-%d]%H:%M:%S`


###manual_properties###
project_name=demo
tomcat_basehome=/var/apache-tomcat-7.0.79_81
tomcat_port=80
shell_environment=/bin/bash


war_Dir=/var/${project_name}/temp
war_Name=${project_name}.war


source_dir=/var/code/${project_name}
docBase=${project_name}
###manual_properties###




#update server environment
echo "**********************************  ${log_time}


*************************************"


#compile code
cd ${source_dir}
git pull
mvn clean
mvn compile
mvn package -DskipTests=true
cd target


#build check funcation
echo "check tomcat status..."
check_tomcat_status(){
      netstat -ant|grep ${tomcat_port} > /dev/null
      t=$?
       if [ $t -eq 0 ]; then
           echo "tomcat is running....port is ${tomcat_port}"
           echo "shutdown tomcat....."
           echo ">>>>>>>shutdown tomcat begin<<<<<<<<"
            ${shell_environment} ${tomcat_basehome}/bin/shutdown.sh
           echo ">>>>>>>shutdown tomcat end <<<<<<<<"
           sleep 5
       elif [ $t -ne 0 ];then
             echo "tomcat is poweroff"
              ${shell_environment} ${tomcat_basehome}/bin/shutdown.sh
             sleep 5
       fi
}


#check tomcat status invoke function
check_tomcat_status


#kill current proc
kill -9 $(ps -aef | grep catalina | grep ${tomcat_basehome} | grep -v grep | awk '{print


$2}')


#copy new
#rm -rf ${source_dir}/target/${docBase}/*
cp -v -r ${source_dir}/target/${docBase}/ ${tomcat_basehome}/webapps/


#reboot tomcat
echo " >>>>>>>  rebooting  tomcat begin <<<<<<<<"
${shell_environment} ${tomcat_basehome}/bin/startup.sh
echo " >>>>>>>  rebooting  tomcat end <<<<<<<<"
echo "the log you can read in canalina.out"
echo "************************ deploy war package into container Successlly


**********************************"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值