自动部署脚本
脚本如下:
#!/bin/sh -x
source_home=git下载后的本地仓库地址
git_path=git的地址,记得加上用户名和密码
tomcat_home=tomcat地址
deploy_war=$source_home/war包路径
deploy_path=$tomcat_home/webapps/ROOT
cd $source_home
git pull $git_path git拉取的分支
cd $source_home
mvn clean package --settings settings地址 -Dskiptest -U -P profiles的id -Dmaven.test.skip=true
sh $tomcat_home/bin/catalina.sh stop
sleep 1s
pidlist=`ps -ef|grep $tomcat_home/conf/ | grep -v "grep"|awk '{print $2}'`
echo "tomcat Id list :$pidlist"
if [ "$pidlist" = "" ]
then
echo "no tomcat pid alive"
else
for pid in ${pidlist}
{
kill -9 $pid
echo "KILL $pid:"
echo "service stop success"
}
fi
rm -rf $deploy_path/*
cp $deploy_war $deploy_path
cd $deploy_path
jar -xvf war包名字.war
sh $tomcat_home/bin/catalina.sh start
sleep 1s
tail -f $tomcat_home/logs/catalina.out