无法从groovy脚本构建Jenkins构建 [英] Fail a Jenkins build from groovy script

查看:360
本文介绍了无法从groovy脚本构建Jenkins构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个时髦的脚本来推广代码.长话短说,我知道该脚本中的某个时间点是否成功.如果不成功,我想使构建失败.有什么办法可以使构建失败吗?

I have a groovy script that goes and promotes code. Long story short, I know at a point of time within that script if it was successful or not. I would like to fail the build if not successful. Is there a way in groovy to fail the build?

示例:

在执行Groovy脚本"插件中.您可以编写代码.

in the "execute Groovy script" plugin. you can write code.

(insert API call to promote code) if(checkPromote()){ //fail build here }

(insert API call to promote code) if(checkPromote()){ //fail build here }

其中"checkPromote"根据促销的状态返回true或false值.

where 'checkPromote' returns a true or false value depending on the status of the promote.

推荐答案

在我看来,中止编程的最优雅方法是声明.

The most elegant way to abort a programm in my opinion is an assertion.

assert condition : "Build fails because..."

这篇关于无法从groovy脚本构建Jenkins构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆