I am building a Jenkins Declarative Pipeline.
Here's a gist of what I'm trying to do(as an arbitrary example)-
I want the matrix to be executed so that each Key-Values list iterates together.
For Example-
Platforms = ["Windows", "Mac", "Linux"]
Browsers = ["Edge", "Chrome", "Firefox"]
I want the output stages to have these pairings for (Platforms,Browsers)-
[("Windows", "Edge"),("Mac", "Chrome"),("Linux", "Firefox")]
In the actual case, this list is 12 long, so I don't want to define as many stages with when directives to pair these values manually, since everything else is the same in these stages.
Is there a way to do this, or a better approach?
You can use an excludes
block to handle this, but it's not particularly pretty.
matrix {
axes {
axis {
name 'PLATFORM'
values 'Windows', 'Mac', 'Linux'
}
axis {
name 'BROWSER'
values 'Edge', 'Chrome', 'Firefox'
}
}
excludes {
// Exclude any pairs that have PLATFORM == Windows, BROWSER != Edge
exclude {
axis {
name 'PLATFORM'
values 'Windows'
}
axis {
name 'BROWSER'
notValues 'Edge'
}
}
// repeat for each expected pair
}
}