继续潜水

导航

 

Jenkins 打完包,执行scp远程发送jar包后重启服务

 

1 set -x
2 pwd
3 scp -r ${WORKSPACE}/hycloud-gateway/target/hycloud-gateway*.jar root@192.168.1.196:/home/huayun-szhqgc/server/hycloud-gateway.jar
4 ssh -tt -p 22 root@192.168.1.196  <<EOF
5     sh /home/huayun-szhqgc/server/shell_hycloud-gateway.sh restart
6     echo "启动服务结束"
7     exit
8 EOF          

 第3行:执行scp远程发送jar包

 第4-8 执行多行代码,

  -tt 非终端

      最后要执行exit退出,不然Jenkins一直会卡着

在sh执行的脚本中 在脚本一开始加上source /etc/profile

 参考:https://www.cnblogs.com/sunpong/p/13660375.html

posted on 2024-05-30 14:32  继续潜水  阅读(80)  评论(0编辑  收藏  举报