1、遇到的错误信息
ERROR: Exception when publishing, exception message [Exec timed out or was interrupted after 120,000 ms]
Build step 'Send build artifacts over SSH' changed build result to UNSTABLE
Finished: UNSTABLE
执行完命令后一直转圈,执行脚本不退出,然后超时出现上述错误信息,实际已启动成功。
2、错误原因
在使用Jenkins进行远程部署时,构建后执行的脚本没有正常退出导致。 jenkins 无法判断命令是否执行完成。
Since you are executing a script from a non-TTY environment; The Jenkins is not able to get the exit properly, out of your script.
意思是:因为你是从一个非tty环境执行脚本;Jenkins不能正常从你的脚本中退出。
3、解决办法
解释:
Since you are executing a script from a non-TTY environment; The Jenkins is not able to get the exit properly, out of your script.
What you want is to exit immediately, after script execution! Don't want to wait for the entire timeout to happen and then disconnect improperly!
Solution: Make it Exec in PTY. (Please tick the check-box as shown in attached screenshot)
4、继续
但是这种情况虽然结果显示success,但是实际并未启动成功,可能的原因是刚启动,pty(伪终端)就断开连接。后来各方搜索又在脚本后加上sleep 1,完美解决。