新建一个任务
General配置:
1、配置丢弃旧的构建
2、配置参数化构建过程
Add parameter -> Git Parameter
3、配置Source Code Management:
配置Additional Behaviours
在add中添加
Clean after checkout
Prune stale remote-tracking branches
Merge before build
4、配置Build
配置Post Steps
添加Add post-build step 中执行shell
shell 脚本:
#/bin/bash
source /etc/profile
APP_NAME=/home/platform/test-1.0-SNAPSHOT.jar
YML=/home/platform/application.yml
function stop(){
pid=`ps auxw|grep $APP_NAME|grep -v grep|awk '{print $2}'`
if [ -n "$pid" ]; then
echo "======to kill the $APP_NAME pid $pid========"
kill -9 $pid
else
echo "not found process..."
fi
}
function start(){
echo "==========start $APP_NAME ============"
nohup java -jar $APP_NAME --spring.config.location=file:$YML >/dev/null 2>&1 &
}
app_home=/home/platform
app_name=test-1.0-SNAPSHOT.jar
stop
rm $app_home/$app_name
mv $app_home/$app_name $app_home/
start
参考资料:
https://cloud.tencent.com/developer/article/1342915
https://blog.csdn.net/zxlhaoren/article/details/50974014
https://www.cnblogs.com/yanghaotai/p/9927843.html