1 新建一个maven项目 ok 进入下一步
2 勾选 丢弃旧的构建 (保持策略自定义即可)
3 勾选 Subversion
Repository URL:svn://xxx.xxx.xxx.xx/svn_repository/trunk/xxxxx
Credentials:自行添加 帐号密码即可
Check-out Strategy:Use 'svn update' as much as possible, with 'svn revert' before update(就是最后一个)
4 Pre Steps --》Add pre-build step --》选择Execute shell
填入
ssh root@xxx.xx.xx.xx > /dev/null 2>&1 << eeooff
sh /usr/local/file/shutdowntomcat.sh
exit
eeooff
5 Post Steps
--》Add pre-build step --》选择Execute shell
填入
scp /root/.jenkins/workspace/collection/*/target/*.war root@xxx.xx.xx.xx:/usr/local/apache-tomcat-8.5.16/webapps
ssh root@xxx.xx.xx.xx > /dev/null 2>&1 << eeooff
sh /usr/local/file/starttomcat.sh
exit
eeooff
上述ip地址均为 tomcat容器所在服务器地址,需要提前配置ssh免密登录
shutdowntomcat.sh
# !/bin/sh
for pid in $(ps -ef | grep apache-tomcat-7.0.76 | cut -c 10-15); do
echo $pid
kill -9 $pid
done
rm -rf /usr/local/apache-tomcat-7.0.76/webapps/baidu*
rm -rf /usr/local/apache-tomcat-7.0.76/work/Catalina/localhost/
rm -rf /usr/local/apache-tomcat-7.0.76/ROOT
rm -rf /usr/local/apache-tomcat-7.0.76/baidu*
#mkdir /usr/local/apache-tomcat-7.0.76/webapps/baidu
#/usr/local/apache-tomcat-7.0.76/bin/startup.sh
#while [ ! -z $(ps -ef | grep curl | grep -v grep | cut -c 9-15) ]
#do
# ps -ef | grep curl | grep -v grep | cut -c 15-20 | xargs kill -9
# ps -ef | grep curl | grep -v grep | cut -c 9-15 | xargs kill -9
#done
starttomcat.sh
# !/bin/sh
#for pid in $(ps -ef | grep apache-tomcat-7.0.76 | cut -c 10-15); do
# echo $pid
# kill -9 $pid
#done
#rm -rf /usr/local/apache-tomcat-7.0.76/webapps/baidu*
#rm -rf /usr/local/apache-tomcat-7.0.76/work/Catalina/localhost/
#mkdir /usr/local/apache-tomcat-7.0.76/webapps/baidu
/usr/local/apache-tomcat-7.0.76/bin/startup.sh
#while [ ! -z $(ps -ef | grep curl | grep -v grep | cut -c 9-15) ]
#do
# ps -ef | grep curl | grep -v grep | cut -c 15-20 | xargs kill -9
# ps -ef | grep curl | grep -v grep | cut -c 9-15 | xargs kill -9
#done
restarttomcat.sh
# !/bin/sh
for pid in $(ps -ef | grep apache-tomcat-7.0.76 | cut -c 10-15); do
echo $pid
kill -9 $pid
done
rm -rf /usr/local/apache-tomcat-7.0.76/work/Catalina/localhost/
rm -rf /usr/local/apache-tomcat-7.0.76/webapps/baidu*
rm -rf /usr/local/apache-tomcat-7.0.76/baidu*
/usr/local/apache-tomcat-7.0.76/bin/startup.sh
#while [ ! -z $(ps -ef | grep curl | grep -v grep | cut -c 9-15) ]
#do
# ps -ef | grep curl | grep -v grep | cut -c 15-20 | xargs kill -9
# ps -ef | grep curl | grep -v grep | cut -c 9-15 | xargs kill -9
#done