Fail hudson build with groovy script

六月ゝ 毕业季﹏ 提交于 2019-12-05 22:01:10

问题


I have a couple of post build actions that I run on my Hudson build. They are currently bash scripts, and if I want to fail the biuld from them, I just return a non-zero value. Is there a way to fail the build from another scripting language (such as groovy)? Do I just write a script that also returns non-zero? Or is there a particular plugin I need to enable this?

thanks, Jeff


回答1:


The Groovy Postbuild Plugin seems to be what you need, and has a method called buildFailure() which sets the build result to FAILURE.




回答2:


A way to do this programmatically within the Groovy script is:

throw new hudson.AbortException("Something was in my eye...")



回答3:


If your post build action is a standard build step (like a shell script). it is enough to exit that shell script with a non-zero value. I don't know if all scripting languages allow you to return a non-zero return value, that will then become the return value of the script (if you don't call exit or an equivalent command specifically in a script than the return value of the last executed command becomes the return value of the script).

If you have troubles with this approach, there is always the option to use the Log Parser Plugin to fail a build on error.



来源:https://stackoverflow.com/questions/4335779/fail-hudson-build-with-groovy-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!