fshehadeh
fshehadeh

Reputation: 458

Jenkins Pipeline: trigger downstream job to run later

I currently have a multibranch project, and I would like the "development" branch build to trigger another top-level Maven Jenkins job. The goals in the multibranch project are kept down to a minimum (build and unit tests), while the top level Maven project is configured to run all kinds of reports ("site site-deploy").

I currently use something like this:

if ("development".equals(branchName)) { stage('Trigger Full Build') { build job: "FullJob" } }

This works as expected, but the disadvantage is that the "build job" step will take up ~40 minutes, which is the time that it taken by the full job. I would like to know if it is possible to trigger the full job from the multibranch job, but allow the full job to run asynchronously (not count against the execution time of the multibranch job)

Upvotes: 12

Views: 16569

Answers (1)

mawi
mawi

Reputation: 593

Have a look into the syntax help for the build pipeline step at http(s)://your-jenkins.com/jenkins/pipeline-syntax. Just select the build step, select the parameters you want and press the generate button to get the corresponding snippet.

The shortcut:

The build step does wait for triggered downstream builds by default. But there is the parameter wait that can be set to false, allowing you to fire and forget in your multibranch pipeline:

if( "development" == branchName) {
    stage("trigger full build") {
        build job: 'FullBuild', wait: false
    }
}

Upvotes: 29

Related Questions