enkins 执行远程脚本命令
go应用执行脚本
/usr/bin/sh /mnt/sh/deploy_go.sh external-api /mnt/app/gee >/dev/null 2>&1 &
java(springboot)应用执行脚本
/usr/bin/sh /mnt/sh/deploy_go.sh external-api /mnt/app/gee >/dev/null 2>&1 &
java 部署脚本deploy.sh,记得部署的时候使用chmod a+x deploy.sh
#!/bin/sh
export BUILD_ID=dontKillMe
export JAVA_HOME=/usr/local/java/jdk1.8.0_222
export JRE_HOME=/usr/local/java/jdk1.8.0_222/jre
#项目名称 xxx.jar
project_name=$1
#部署路径
deploy_path=$2
#文件路径
upload_path=/mnt/pkg/$1
if [ -f "${upload_path}" ]; then
# kill process
ps -ef|grep ${project_name}|grep java|awk '{print $2}'|xargs kill -9
# remove file
rm -rf ${deploy_path}/${project_name}
# backup file
cp -r ${upload_path} ${deploy_path}/${project_name}_`date "+%Y%m%d%H%M%S"`
# move file
mv ${upload_path} ${deploy_path}/${project_name}
# exec deploy
cd ${deploy_path} && nohup java -jar ${deploy_path}/${project_name} >/dev/null 2>&1 &
else
exit 0
fi
go 部署脚本deploy_go.sh,创建脚本后同样需要chmod a+x deploy_go.sh
#!/bin/sh
export BUILD_ID=dontKillMe
#example gee
project_name=$1
#deploy path
deploy_path=$2
#file path
upload_path=/mnt/pkg/$1
if [ -f "${upload_path}" ]; then
# kill process
kill -9 `ps -C ${project_name} -o pid=`
# remove file
rm -rf ${deploy_path}/${project_name}
# backup file
cp -r ${upload_path} ${deploy_path}/${project_name}_`date "+%Y%m%d%H%M%S"`
# move file
mv ${upload_path} ${deploy_path}/${project_name}
# add exec auth
chmod a+x ${deploy_path}/${project_name}
# exec deploy
cd ${deploy_path} && nohup ./${project_name} > ./${project_name}.log 2>&1 &
else
exit 0
fi
USB Microphone https://www.soft-voice.com/
Wooden Speakers https://www.zeshuiplatform.com/
亚马逊测评 www.yisuping.cn
深圳网站建设www.sz886.com
有疑问加站长微信联系(非本文作者)