1。新建任务
2.配置源码管理,关联git仓库
3.构建---》执行shell
time=`date +%d%m%d%H%M`
cd /root/.jenkins/workspace/shanxiang-pc
mvn clean package -Pprod
if [ $? -ne 0 ]; then
echo "====Build uboot failed!===="
exit 1
else
cd /usr/local/apache-tomcat-7-8098_gw/webapps
#stop app
stat=`ps -ef|grep apache-tomcat-7-8098_gw| grep -v grep|awk '{print $2}'`
if [ $stat ]; then
kill -9 ${stat}
fi
#创建文件夹备份
#mkdir -pv /usr/local/apache-tomcat-7-8098_gw/webapps/${time}
#mv *.war /usr/local/apache-tomcat-7-8098_gw/webapps/${time}/
rm -rf gw
rm -rf admin
cp -rf /root/.jenkins/workspace/shanxiang-pc/shanxiang-website/target/shanxiang-website-prod.war /usr/local/apache-tomcat-7-8098_gw/webapps/gw.war
cp -rf /root/.jenkins/workspace/shanxiang-pc/shanxiang-mgr-web/target/shanxiang-mgr-web-prod.war /usr/local/apache-tomcat-7-8098_gw/webapps/admin.war
cd /usr/local/apache-tomcat-7-8098_gw/bin
BUILD_ID=dontKillMe ./startup.sh
echo "====Build ruboot ok!===="
fi
到此配置完成,直接构建项目完事!
番外篇,springboot 自动部署,只是第三步构建略有差距,其他都一样