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)
Use build job plugin for that task in order to trigger other jobs from jenkins file. You can add variety of logic to your execution such as parallel ,node and agents options and steps for triggering external jobs.
Add a Schedule to a Jenkins JobHead back to the job configuration and click the Build Triggers tab. Now, check the Build periodically box in the Build Triggers section. This will open the scheduling text area. Next, let's set the job to run every five minutes.
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
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With