jenkins自动部署软件包及重新加载
1先做好自己需要上传的服务器
保存完之后回到首页,选择需要搭建的,点击名称
服务器搭建完毕,现在需要配置传包及重启。
下面先上穿包位置查找 文章最后会有Exec command的例子。
回到首页先点击需要查找的名字
查找完成。
最后根据自己生产环境写出代码,示例仅供参考:
《停止脚本》:
#!/bin/sh
APP_NAME=API-ServiceImpl-1.0-SNAPSHOT.jar
tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -15 $tpid
fi
sleep 5
tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi
《传包及启动脚本》:
cd provider
mv -f ./API-ServiceImpl-1.0-SNAPSHOT.jar ./old/API-ServiceImpl-1.0-SNAPSHOT.jar-last
mv ../API-ServiceImpl-1.0-SNAPSHOT.jar ./
rm -f tpid
source /etc/profile
nohup java -server -jar API-ServiceImpl-1.0-SNAPSHOT.jar --spring.profiles.active=test > /dev/null &
echo $! > tpid