标签:cti snap root 修改文件 pid 包名 files 自动化部署 echo
SERVER_NAME=project-name
JAR_NAME=project-name-0.0.1-SNAPSHOT
Jenkins 自动化部署sh参考:
打包生成jar包的目录
JAR_PATH=/var/lib/jenkins/workspace/otc-ud/target
JAR_WORK_PATH=/usr/soft/jm
echo "复制jar包到执行目录:cp $JAR_PATH/$JAR_NAME.jar $JAR_WORK_PATH"
cp $JAR_PATH/$JAR_NAME.jar $JAR_WORK_PATH
echo "复制jar包完成"
cd $JAR_WORK_PATH
chmod 755 $JAR_NAME.jar
ssh -tt root@43.249.193.149 -p 15777 << remotessh
cd /usr/local/application/new-path
mv project-name-0.0.1-SNAPSHOT.jar "project-name-0.0.1-SNAPSHOT-"date +%Y%m%d%H%M%S
".jar"
exit
remotessh
scp -P 15777 /usr/soft/jm/project-name-0.0.1-SNAPSHOT.jar root@43.249.193.149:/usr/local/application/new-path/
/usr/bin/sshpass -p sk8daXQ9MJOUCewp ssh root@43.249.193.149 -p 15777 ‘sh /usr/local/application/new-path/sh/project-name.sh‘
/usr/local/application/new-path/sh/project-name.sh:
SERVER_NAME=project-name
JAR_NAME=project-name-0.0.1-SNAPSHOT
echo "查询进程id-->$SERVER_NAME"
PID=ps -ef | grep "$SERVER_NAME" |grep -v grep | awk ‘{print $2}‘
echo "得到进程ID:$PID"
echo "结束进程"
for id in $PID
do
kill -9 $id || true
echo "killed $id"
done
echo "结束进程完成"
nohup /usr/local/java/jdk1.8.0_131/bin/java -jar /usr/local/application/new-path/project-name-0.0.1-SNAPSHOT.jar --spring.profiles.active=prod149 &
echo "执行完毕"
标签:cti snap root 修改文件 pid 包名 files 自动化部署 echo
原文地址:https://www.cnblogs.com/LoveShare/p/14445459.html