Fail hudson build with groovy script

醉酒当歌 提交于 2019-12-04 03:17:13

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

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

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

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.

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