How to trigger a job for each configuration in a matrix project

4.4k views Asked by At

I have to achieve the following : I have a multiconfiguration project A having two configuration C1 and C2, now for each successfull configuration I want to build another project B, say:

  • if C1-success and C2-fails then C1 --> B
  • if C1-fail and C2-success then C2 --> B
  • if C1-success and C2-success then C1 --> B and then C2 --> B (only one instance of B can run at a time)

Currently if one of the configuration fails then the parent is marked as fail which stops triggering of the downstream project.

1

There are 1 answers

0
KeepCalmAndCarryOn On

You can use the parameterized trigger plugin to trigger job B at the end of C and pass a parameter in to B which is the name of the matrix parameter in C - this is named after the label name

As for multiple job B running together, if you keep the concurrent runs if required box unchecked in job B it will be fine


EDIT

it seems the plugin supports this native without using parameters - from the plugin page

Use of the plugin in a Matrix job
Post build task
When using the trigger parameterized build as a post build task for a matrix job the
triggering will be be done
once when all of the different matrix configurations have completed.
In this case some of the Environment variables may not be resolvable as passing them 
to downstream jobs will fail.

Environment variables that should be available are the the default shell ones
(<yourserver:port>/env-vars.html) and ones defined as Parameters.
Variables added by the other plugins as a buildwrappers may not be available.

Build step
When using the trigger parameterized build as a buildstep it will be called for 
every different configuration, so if triggering another project with no parameters it 
will be done the same number of times as you have configurations, possible causing the
triggered job to run more than once.

However this also allows you to trigger other jobs with parameters relating to the 
current configuration, i.e. triggering a build on the same node with the same JDK.