且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Groovy中为Jenkins预发送脚本

更新时间:2023-12-05 14:34:58

使用 Build.getCauses()方法.它将返回生成原因的列表.遍历它,并检查是否存在 hudson.model.Cause的对象.上游原因.

Use Build.getCauses() method. It will return a list of causes for the build. Loop over it and check if there is an object of hudson.model.Cause.UpstreamCause among them.

要获取构建对象,请使用以下代码片段:

To get the build object, use the following code snippet:

def thr = Thread.currentThread()
def build = thr?.executable

仅供参考,这是完整的 Jenkins模块API的链接.

FYI, here is a link to the complete Jenkins Module API.