I am trying to create a multi-configuration project that tests a bunch of builds that defines a compatibility matrix (for example by browser and os). I would like to define the steps for a single combination via Jenkinsfile
.
How can I achieve this? I can create a pipeline parameterized build which depends on JenkinsFile but I can't figure out how to connect it to the multi-configuration build.
It does not appear to be possible to have a Jenkinsfile as a buildstep in a multi-configuration project. A Jenkinsfile is used in a Pipeline job which is a jobtype aswell and Jenkins does not support (easy) conversion between jobtypes. In addition to that, a buildstep implies that it is run on a particular node in an executor slot. A Jenkinsfile however is evaluated on the master and itself defines buildsteps (with their node labels) which would inherently clash if it was run in a buildstep itself.
It is possible to trigger a pipeline through a multi-configuration job and supply it with the parameters from the multi-configuration job. (I also used the parameterized trigger plugin to do this)
My pipeline job has two text parameters, label
and version
with a example Jenkinsfile that looks like this:
node(this.label){
println this.version
}
My multi-configuration job has the following configuration:
version
with values alpha beta gamma
and a slave axis label
with a selected nodeversion=${version}
and label=${label}
This setup leads to the pipeline job being called 3 times (as I have only one node selected), each time with a different version and running on my specified label. Here is one of the logs:
[Pipeline] node
Running on master in /var/lib/jenkins/jobs/pipelinejob/workspace
[Pipeline] {
[Pipeline] echo
gamma
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
This solution works if you only want to pass text based parameters or label names. It will be considerably trickier to use if you want to do something like "build with different jdks". I hope it is still helpful though.
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