问题
Is there an environment variable that captures the downstream job's build number ? I am using build step in pipeline as code.
回答1:
Not an environment variable, but an object property:
downstreamBuild = build 'myDownstreamJob'
downstreamBuildNumber = downstreamBuild.rawBuild.id
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.
来源:https://stackoverflow.com/questions/46352379/capture-build-number-of-downstream-job-in-jenkins-code-as-pipeline