1. Jenkins系统配置配置ssh
远程服务器测试联通
2. Jenkins配置构建后操作
Jenkins配置
Exec in pty 电
3. ssh脚本
export LANG="en_US.UTF-8"
. /etc/profile
# 进入到项目
cd /root/projects/demo/pig-eureka/target/
# 找到原进程,并杀掉
pid=$(ps -ef | grep java| grep pig-eureka|awk -F '[ ]+' '{print $2}')
kill -9 $pid
#启动jar
nohup java -jar pig-eureka.jar --server.port=8085 -server -Xmx1000m -Xms1000m -Xmn700m -XX:+UseParallelGC &
echo "starting service..."
sleep 20
#根据重启后是否又当前应用判断启动是否成功
pid=$(ps -ef | grep java| grep pig-eureka|awk -F '[ ]+' '{print $2}')
echo $pid
if [ -z $pid ];then
echo "启动失败"
exit 1
else
echo $Project_name : $pid "SUCCESS"
fi
4. 点击构建项目,查看输出结果
lsof -i:port在服务器查看启动进程
5. 出现的问题和解决
SSH: Transferred 0 file(s)
https://www.wandouip.com/t5i245436/
Jeknis乱码问题
https://blog.csdn.net/gld824125233/article/details/52549557
Jenkins解决shell乱码问题
https://blog.csdn.net/qq_35732831/article/details/85236562
Exec in pty
参考文档
https://www.cnblogs.com/FengGeBlog/p/9767983.html