jenkins脚本-jar包脚本

脚本1:(包名我隐去了)

#! /bin.bash
# by fencatn
echo "Stopping SpringBoot Application"
jarfile=file.jar
#指定启动的配置文件是dev/test/pro
export SPRING_PROFILES_ACTIVE=test
pid=`ps -ef | grep $jarfile | grep -v grep | awk '{print $2}'`
echo $pid
echo "--------kill start--------------"
if [ -n "$pid" ]
then
echo "kill -9 的pid:" $pid
kill -9 $pid
fi
echo "--------kill finish-----------------"
echo "--------replace start--------------"
DATE=$(date +%Y%m%d%H%M%S)
mv /root/xxx/$jarfile /usr/local/project/xxx/$jarfile.$DATE.bak
mv /usr/local/project/xxx/$jarfile /root/xxx
echo "--------replace finish-----------------"
echo "Execute shell Finish"
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.3.7-0.el7_6.x86_64
echo "Executing program....."
nohup ${JAVA_HOME}/bin/java -jar /root/xxx/$jarfile &>/root/xxx/$DATE.nohup.log &

脚本2:(先占个座先)

此条目发表在jenkins分类目录,贴了标签。将固定链接加入收藏夹。

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注