Add support for `when` within `matrix.include`.
Feature request
Using matrix.include is helpful for reducing duplication in pipeline definitions when there are specific parameter configurations that are needed. All possible parameter configuration are not, however, needed for all PipelineRuns. It would be beneficial if we could use parameters to configure which items in matrix.include are actually used for a PipelineRun.
Use case
As a user, I want to be able to customize my pipeline runs only using the pipeline parameters. If I do not need all configured matrix includes, I should not need to modify the pipeline definition.
Pipeline definition snippet (i.e. can be referenced using the git resolver):
- name: build-containers-multi-platform
matrix:
include:
- name: amd64
params:
- name: IMAGE
value: $(params.output-image)-amd64
- name: PLATFORM
value: $(params.platform-amd64)
when:
- input: "amd64"
operator: in
values: "$(params.enabled-platforms[*])"
- name: arm64
params:
- name: IMAGE
value: $(params.output-image)-arm64
- name: PLATFORM
value: $(params.platform-arm64)
when:
- input: "arm64"
operator: in
values: "$(params.enabled-platforms[*])"
- name: ppc64le
params:
- name: IMAGE
value: $(params.output-image)-ppc64le
- name: PLATFORM
value: $(params.platform-ppc64le)
when:
- input: "ppc64le"
operator: in
values: "$(params.enabled-platforms[*])"
- name: s390x
params:
- name: IMAGE
value: $(params.output-image)-s390x
- name: PLATFORM
value: $(params.platform-s390x)
when:
- input: "s390x"
operator: in
values: "$(params.enabled-platforms[*])"
Pipeline run snippet (pipeline is not running properly on ppc64le or s390x, so we will disable them):
spec:
params:
- name: enabled-platforms
value:
- arm64
- name: platform-arm64
value: linux/arm64
- name: platform-ppc64le
value: linux-m4.xl/ppc64le
- name: platform-s390x
value: linux/s390x
+1!
In case someone comes across this issue, this is a request to add support for the when attribute for the items in the matrix.includes list.
/assign
A small problem, when.values should be an array
when:
- input: "amd64"
operator: in
values:
- "$(params.enabled-platforms[*])"