本文共 2350 字,大约阅读时间需要 7 分钟。
ERROR: Exception when publishing, exception message [Exec timed out or was interrupted after XXX ms
错误信息:Waiting for Jenkins to finish collecting data
[JENKINS] Archiving /shfb_30/.jenkins/workspace/apollo_test/pom.xml to com.shfb.mobile/mobile/1.0-SNAPSHOT/mobile-1.0-SNAPSHOT.pom[JENKINS] Archiving /shfb_30/.jenkins/workspace/apollo_test/target/mobile-1.0-SNAPSHOT.jar to com.shfb.mobile/mobile/1.0-SNAPSHOT/mobile-1.0-SNAPSHOT.jarchannel stoppedSSH: Connecting from host [iZ25txgf5wsZ]SSH: Connecting with configuration [45.26_jenkins_docker] ...SSH: EXEC: STDOUT/STDERR from command [/shfb_50G/apollo/apollo.sh] ...开始运运行脚本SSH: Disconnecting configuration [45.26_jenkins_docker] ...ERROR: Exception when publishing, exception message [Exec timed out or was interrupted after 68,342 ms]Build step 'Send build artifacts over SSH' changed build result to UNSTABLEFinished: UNSTABLE我在使用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不能正常从你的脚本中退出。解决办法:外国网友解释:
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不能正确地离开你的脚本。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)解决方案:在PTY中使用Exec参考地址:
我最近(2016-10-25)在配置新项目时,发现,即使是勾选了Exec in pty,出现了项目不能启动的问题。12执行的结果是项目没有启动:
之后我又去查资料,依然是在那个外国网站的下面一个人回答中,找到了解决的方法!
可能的原因是因为,在执行openapi start 命令时,刚启动,pty(伪终端)就断开连接,解决的办法就是,让脚步在后台运行,也就即使伪终端断开了,项目依然可以启动完成。之后我执行的脚本改为nohup sh ggf10service.sh1其实就是在前面加上nohup;外国网友后面还加了sleep 1:nohup sh ggf10service.sh & sleep 1
,我没有加也可以!这里还需要注意的地方是,启动成功后,Jenkins控制台会打印这么一句话nohup: ignoring input and appending output to `nohup.out'1也就是说,当我们使用nohup命令的的时候,日志会被打印到nohup.out文件中去。如果我们不做任何处理,会随着每次的重新启动,nohup.out会越来越大。所以我在我执行的脚本中添加了Cat /dev/null > nohup.out这样每次启动时,都会先清空掉这个文件。公网构建mobile 和uservice 说明:地址:101.201.31.68/jenkinsMobile 项目名称:mobile-apiUservice 项目名称:uservice提交代码后,无需调整其他参数,直接构建即可。 转载于:https://blog.51cto.com/11520242/2170632