在Jenkins代码中以管道方式捕获下游作业的内部版本号 [英] capture build number of downstream job in Jenkins code as pipeline

查看:151
本文介绍了在Jenkins代码中以管道方式捕获下游作业的内部版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在捕获下游作业的内部版本号的环境变量? 我正在使用管道中的构建步骤作为代码.

Is there an environment variable that captures the downstream job's build number ? I am using build step in pipeline as code.

推荐答案

不是环境变量,而是对象属性:

Not an environment variable, but an object property:

downstreamBuild = build 'myDownstreamJob'
downstreamBuildNumber = downstreamBuild.rawBuild.id

请注意,您将需要禁用Groovy沙箱或获得脚本批准才能使用rawBuild.另外,您不能在构建步骤中使用wait: false,因为build()wait: false调用时会返回null.

Note that you will either need to disable the Groovy sandbox or get script approvals in order to use rawBuild. Also, you cannot use wait: false with your build step, since build() returns null when called with wait: false.

这篇关于在Jenkins代码中以管道方式捕获下游作业的内部版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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