In order to get the fastest feedback possible, we occasionally want Jenkins jobs to run in Parallel. Jenkins has the ability to start multiple downstream jobs (or 'fork' the pipeline) when a job finishes. However, Jenkins doesn't seem to have any way of making a downstream job only start of all branches of that fork succeed (or 'joining' the fork back together).
Jenkins has a "Build after other projects are built" button, but I interpret that as "start this job when any upstream job finishes" (not "start this job when all upstream jobs succeed").
Here is a visualization of what I'm talking about. Does anyone know if a plugin exists to do what I'm after?
When I originally posted this question in 2012, Jason's answer (the Join and Promoted Build plugins) was the best, and the solution I went with.
However, dnozay's answer (The Build Flow plugin) was made popular a year or so after this question, which is a much better answer. For what it's worth, if people ask me this question today, I now recommend that instead.
Yes it's possible. Doc: If this option is checked, Jenkins will schedule and execute multiple builds concurrently (provided that you have sufficient executors and incoming build requests.)
You will need to configure your "child" job so that it can run in parallel by checking the "Execute concurrent builds if necessary" in the job configuration. Whatever set of slaves provide the connection to the embedded devices will need enough executors to run your jobs in parallel.
Many 'phases' can be set up as part of the MultiJob project and each phase "contains" one or more "other" Jenkins jobs. When the MultiJob project is run, the phases will be run sequentially. Therefore, in order to run N jobs sequentially, add N phases to your MultiJob project, and then add one job to each phase.
Select a job that triggers a remote one and then go to Job Configuration > Build section > Add Build Step > Trigger builds on remote/local projects option. This configuration allows you to trigger another exciting job on a different CM (remote). The downstream job name part will autocomplete.
You can use the Pipeline Plugin (formerly workflow-plugin
).
It comes with many examples, and you can follow this tutorial.
e.g.
// build stage 'build' ... // deploy stage 'deploy' ... // run tests in parallel stage 'test' parallel 'functional': { ... }, 'performance': { ... } // promote artifacts stage 'promote' ...
You can also use the Build Flow Plugin. It is simply awesome - but it is deprecated (development frozen).
Create jobs for:
in the upstream (here build
) create a unique artifact, e.g.:
echo ${BUILD_TAG} > build.tag
archive the build.tag
artifact.
build.tag
file and records fingerprints, you will be able to track the parent.promotion
job is successful.PARENT_JOB_NAME
and PARENT_BUILD_NUMBER
Copy the artifacts from upstream build
job using the Copy Artifact Plugin
${PARENT_JOB_NAME}
${PARENT_BUILD_NUMBER}
build.tag
Record fingerprints; that's crucial.
Do the same as the above, to establish upstream-downstream relationship. It does not need any build step. You can perform additional post-build actions like "hey QA, it's your turn".
// start with the build parent = build("build") parent_job_name = parent.environment["JOB_NAME"] parent_build_number = parent.environment["BUILD_NUMBER"] // then deploy build("deploy") // then your qualifying tests parallel ( { build("functional tests", PARENT_BUILD_NUMBER: parent_build_number, PARENT_JOB_NAME: parent_job_name) }, { build("performance tests", PARENT_BUILD_NUMBER: parent_build_number, PARENT_JOB_NAME: parent_job_name) } ) // if nothing failed till now... build("promotion", PARENT_BUILD_NUMBER: parent_build_number, PARENT_JOB_NAME: parent_job_name) // knock yourself out... build("more expensive QA tests", PARENT_BUILD_NUMBER: parent_build_number, PARENT_JOB_NAME: parent_job_name)
good luck.
There are two solutions that I have used for this scenario in the past:
Use the Join Plugin on your "deploy" job and specify "promote" as the targeted job. You would have to specify "Functional Tests" and "Performance Tests" as the joined jobs and start them via in some fashion, post build. The Parameterized Trigger Plugin is good for this.
Use the Promoted Builds Plugin on your "deploy" job, specify a promotion that works when downstream jobs are completed and specify Functional and Performance test jobs. As part of the promotion action, trigger the "promote" job. You still have to start the two test jobs from "deploy"
There is a CRITICAL aspect to both of these solutions: fingerprints must be correctly used. Here is what I found:
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