jenkins执行脚本不退出
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.jar
channel stopped
SSH: 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 UNSTABLE
Finished: UNSTABLE
我在使用Jenkins進行遠程部署時,構(gòu)建后執(zhí)行的腳本沒有正常退出導(dǎo)致。
我的腳本沒有寫錯,干的事情就是啟動項目。
而導(dǎo)致它沒有正常退出的原因是:
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環(huán)境執(zhí)行腳本;Jenkins不能正常從你的腳本中退出。
解決辦法:
外國網(wǎng)友解釋:
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.
因為您正在執(zhí)行一個非tty環(huán)境的腳本;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!
您想要的是在腳本執(zhí)行后立即退出!不要等待整個超時發(fā)生,然后錯誤地斷開連接!
Solution: Make it Exec in PTY. (Please tick the check-box as shown in attached screenshot)
解決方案:在PTY中使用Exec
參考地址:http://stackoverflow.com/questions/11290540/jenkins-text-finder-unable-to-success-my-build/22011893#22011893
我最近(2016-10-25)在配置新項目時,發(fā)現(xiàn),即使是勾選了Exec in pty,出現(xiàn)了項目不能啟動的問題。
?1
?2
?
執(zhí)行的結(jié)果是項目沒有啟動:
之后我又去查資料,依然是在那個外國網(wǎng)站的下面一個人回答中,找到了解決的方法!
可能的原因是因為,在執(zhí)行openapi start 命令時,剛啟動,pty(偽終端)就斷開連接,
解決的辦法就是,讓腳步在后臺運行,也就即使偽終端斷開了,項目依然可以啟動完成。
之后我執(zhí)行的腳本改為
nohup sh ggf10service.sh
?1
其實就是在前面加上nohup;
外國網(wǎng)友后面還加了sleep 1:nohup sh ggf10service.sh & sleep 1,
我沒有加也可以!
這里還需要注意的地方是,啟動成功后,Jenkins控制臺會打印這么一句話
nohup: ignoring input and appending output to `nohup.out'
?1
也就是說,當我們使用nohup命令的的時候,日志會被打印到nohup.out文件中去。
如果我們不做任何處理,會隨著每次的重新啟動,nohup.out會越來越大。
所以我在我執(zhí)行的腳本中添加了
Cat /dev/null > nohup.out
這樣每次啟動時,都會先清空掉這個文件。
公網(wǎng)構(gòu)建mobile 和uservice 說明:
地址:101.201.31.68/jenkins
Mobile 項目名稱:mobile-api
Uservice 項目名稱:uservice
提交代碼后,無需調(diào)整其他參數(shù),直接構(gòu)建即可。
轉(zhuǎn)載于:https://blog.51cto.com/11520242/2170632
總結(jié)
以上是生活随笔為你收集整理的jenkins执行脚本不退出的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用MATLAB画圣诞树的源代码
- 下一篇: 最简单的基于FFmpeg的推流器(以推送