Is there an environment variable that captures the downstream job's build number ? I am using build step in pipeline as code.
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
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.