配置jenkins的项目

新建一个任务
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

猜你喜欢

转载自blog.csdn.net/weixin_41202038/article/details/86489873