Jenkins配置在远程服务器上执行shell脚本
方式一:通过SSH免密方式执行
说明:Jenkins部署在ServerA:10.1.1.74上,要运行的程序在ServerB:10.1.1.196
分两步
第一步:Linux Centos7配置SSH免密登录
第二步:Jenkins配置Execute shell
ssh 10.1.1.196 "cd /home/cg/hmf_app/apiTest;./runAOEC.sh $HOST"
#$HOST是shell脚本的传参,如果没有可不配置


第三步:查看执行结果
测试结果返回

方式二:Jenkins执行配置SSH执行
第一步:配置SSH节点,并调通
「系统管理」------「系统设置」,添加ssh远程节点,并调通。


第二步:创建Jenkins项目,并配置SSH执行
首先创建一个自由风格的项目,如图:

备注:勾选:Verbose output in console,代表可以在控制台看到执行结果,不勾选虽然执行成功了那么看不到。

备注:Send files or execute commands over SSH配置点击高级
- 勾选Exec in pty
- Exec timeout (ms)修改为0
第三步:查看执行结果:
测试结果返回

参考:Jenkins构建(8):Jenkins 执行远程shell :Send files or execute commands over SSH
参考:Jenkins构建(9):Jenkins远程服务器SSH构建时报错Exec timed out120000_exec in pty