The Jenkins Pipeline plugin (aka Workflow) can be extended with other Multibranch
plugins to build branches and pull requests automatically.
What would be the preferred way to run multiple configurations? For example, building with Java 7 and Java 8. This is often called matrix configuration (because of the multiple combinations such as language version, framework version, ...) or build variants.
I tried:
- executing them serially as separate
stage
steps. Good, but takes more time than necessary. - executing them inside a
parallel
step, with or withoutnode
s allocated inside them. Works but I cannot use thestage
step inside parallel for known limitations on how it would be visualized.
Is there a recommended way to do this?
TLDR: Jenkins.io wants you to use nodes for each build.
Vanilla Jenkins Node blocks within a stage would look like:
Further extending this notion Cloudbees writes about parallelism and distributed builds with Jenkins. Cloudbees workflow for you might look like:
Your requirements of visualizing the different builds in the pipeline would could be satisfied with either workflow, but I trust the Jenkins documentation for best practice.
EDIT
To address the visualization @Stephen would like to see, He's right - it doesn't work! The issue has been raised with Jenkins and is documented here, the resolution of involving the use of 'labelled blocks' is still in progress :-(
If you try to use a stage in a parallel job, you're going to have a bad time.
It seems like there is relief coming at least with the BlueOcean UI. Here is what I got (the
tk-*
nodes are the parallel steps):As noted by @StephenKing, Blue Ocean will show parallel branches better than the current stage view. A planned upcoming version of the stage view will be able to show all the branches, though it will not visually indicate any nesting structure (would look the same as if you ran the configurations serially).
In any event, the deeper issue is that you will essentially only get a pass/fail status for the build overall, pending a resolution to JENKINS-27395 and related requests.
In order to test each commit on several platforms, I've used this base Jenkinsfile skeleton:
With this it's relatively easy to switch from a sequential to a parallel execution, each of them having their pros and cons:
I'm using the sequential execution for the time being, until I find a better solution.