jenkins fails on building a downstream job jenkins fails on building a downstream job jenkins jenkins

jenkins fails on building a downstream job


I actually managed to fix this by paying more attention to the definition of the build step. Since all my downstream jobs are defined as multibranch pipeline jobs, their structure is folder-like, with each item in the folder representing a separate job. Thus the correct way to call the downstream jobs was not build job: 'my-job', propagate: true, wait: true, but rather build job: "my-job/my-branch-name", propagate: true, wait: true.

Also, unrelated to the question but related to the issue at hand, make sure you always have at least one more executor free on the jenkins machine, since the wait on syntax will consume one thread for the waiting job and one for the job being waited on, and you can easily find yourself in a resource-starvation type situation.

Hope this helps


This looks like JENKINS-45443 which includes the comment

Pipeline has no support for the upstream/downstream job system, in part due to technical limitations, in part due to the fact that there is no static job configuration that would make this possible except by inspecting recent build metadata.

But it also offer the workaround:

as long as the solution is still ongoing, I include here our workaround. It is based in the rtp (Rich Text Publisher) plugin, that you should have installed to make it work:

At the end of our Jenkinsfile and after triggering the job, we wait it to finish. In that case, build() returns the object used to run the downstream job. We get the info from it.

Warning: getAbsoluteUrl() function is a critical one. Use it at your own risk!

def startedBld = build(    job: YOUR_DOWNSTREAM_JOB,    wait: true, // VERY IMPORTANT, otherwise build () does not return expected object    propagate: true)// Publish the started build information in the Build resultdef text = '<h2>Downstream jobs</h2>Started job <a href="' + startedBld.rawBuild.getAbsoluteUrl () + '">' + startedBld.rawBuild.toString () + '</a>'rtp (nullAction: '1',parserName: 'HTML', stableText: text)

This issue is part of JENKINS-29913, opened for the past two years:

Currently DependencyGraph is limited to AbstractProject, making it impossible for Workflows to participate in upstream/downstream relationships (in cases where job chaining is required, for example due to security constraints).

It refers the RFE (Request for Enhancement) JENKINS-37718, based on another (unanswered) Stack Overflow question.