Fail hudson build with groovy script

2019-04-06 15:12发布

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

3条回答
【Aperson】
2楼-- · 2019-04-06 15:39

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

throw new hudson.AbortException("Something was in my eye...")
查看更多
我只想做你的唯一
3楼-- · 2019-04-06 15:48

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

查看更多
倾城 Initia
4楼-- · 2019-04-06 15:53

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.

查看更多
登录 后发表回答