Sometimes it is handy to have some jobs running in parallel in Jenkins, en have other jobs starten only when all parallel jobs have been finished.
There are multiple ways to do this, I have chosen the following:
Step one: Define the parallel jobs to be run after the git checkup job
When you want to run multiple jobs in parallel after e.g. the checkout job, you can specify these multiple jobs in the build other jobs.
You can have a comma separated list of jobs that can be run in parallel there.
Step two: Specify the job that needs to be run when all parallel jobs are finished
On one of the jobs that run in parallel you specify the jobs than needs to be run after all parallel jobs are finished e.g. the “upload artifacts job”.
Now when the checkout job is finished, the parallel jobs are starten, but the “upload artifacts jobs” will still not wait until all parallel jobs are finished.
To solve this we need the “Build Block Plugin”.
Step three: Install the Build Blocker Plugin
In Jenkins plugin page, install the Build Blocker Plugin
Step 4: In the “Upload artifacts job”, wait until all parallel jobs are finished
In the “Upload artifacts job”, you should now see an option: block build if certain jobs are running.
Enable this option and configure all parallel jobs for which you want to wait.
After this, Jenkins will run the parallel jobs after the project is checked out. When all parallel jobs are finished, the “upload artifacts” job is started.