简体   繁体   中英

Fail hudson build with groovy script

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

在Groovy脚本中以编程方式执行此操作的方法是:

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

Groovy Postbuild插件似乎是您所需要的,并且有一个名为buildFailure()的方法, buildFailure()构建结果设置为FAILURE。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM