ERROR: Exception when publishing, exception message [Exec timed out or was interrupted after XXX ms

jenkins执行脚本不退出

我遇到的错误如下:

错误信息

ERROR: Exception when publishing, exception message [Exec timed out or was interrupted after XXX ms_第1张图片

我在使用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不能正常从你的脚本中退出。

解决办法:

ERROR: Exception when publishing, exception message [Exec timed out or was interrupted after XXX ms_第2张图片

外国网友解释:

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)

参考地址:http://stackoverflow.com/questions/11290540/jenkins-text-finder-unable-to-success-my-build/22011893#22011893

我最近(2016-10-25)在配置新项目时,发现,即使是勾选了Exec in pty,出现了项目不能启动的问题。

ERROR: Exception when publishing, exception message [Exec timed out or was interrupted after XXX ms_第3张图片
ERROR: Exception when publishing, exception message [Exec timed out or was interrupted after XXX ms_第4张图片

执行的结果是项目没有启动:

ERROR: Exception when publishing, exception message [Exec timed out or was interrupted after XXX ms_第5张图片

之后我又去查资料,依然是在那个外国网站的下面一个人回答中,找到了解决的方法!
可能的原因是因为,在执行openapi start 命令时,刚启动,pty(伪终端)就断开连接,
解决的办法就是,让脚步在后台运行,也就即使伪终端断开了,项目依然可以启动完成。

之后我执行的脚本改为
nohup sh ggf10service.sh
其实就是在前面加上nohup;
外国网友后面还加了sleep 1:`nohup sh ggf10service.sh & sleep 1`,
我没有加也可以!
这里还需要注意的地方是,启动成功后,Jenkins控制台会打印这么一句话
nohup: ignoring input and appending output to `nohup.out'
也就是说,当我们使用nohup命令的的时候,日志会被打印到nohup.out文件中去。
如果我们不做任何处理,会随着每次的重新启动,nohup.out会越来越大。
所以我在我执行的脚本中添加了
cp /dev/null nohup.out
这样每次启动时,都会先清空掉这个文件。

你可能感兴趣的:(Jenkins,play,Java,Jenkins,pty,nohup)