Amit
Amit

Reputation: 131

Get Downstream Job Details in the Upstream Job

I need to get the downstream job details so that I can update this in my Upstream Job short desc or some log file.

But I'm unable to find any call that will work. For getting the Upstream Job info, there is getUpstreamCause(..) but nothing similar for DownstreamCause.

Upvotes: 0

Views: 904

Answers (2)

touseef yousuf
touseef yousuf

Reputation: 1


def startedJobld = build(
    job: YOUR_DOWNSTREAM_JOB,
    wait: true, //  **IMPORTANT, otherwise build () does not return expected object**
    propagate: true

println startedJobld .getId()

)

Upvotes: 0

Amit
Amit

Reputation: 131

I've found a solution to this. Javadoc reference : https://javadoc.jenkins.io/plugin/workflow-support/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper.html

def job = build job: 'DownstreamJob'
println job.getId()

The javadoc has all the details I require.

Upvotes: 1

Related Questions