Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for when within matrix.include. #8152

Open
arewm opened this issue Jul 25, 2024 · 3 comments
Open

Add support for when within matrix.include. #8152

arewm opened this issue Jul 25, 2024 · 3 comments
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@arewm
Copy link

arewm commented Jul 25, 2024

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
@arewm arewm added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 25, 2024
@lcarva
Copy link
Contributor

lcarva commented Jul 25, 2024

+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.

@chengjoey
Copy link
Member

/assign

@chengjoey
Copy link
Member

A small problem, when.values should be an array

when:
- input: "amd64"
  operator: in
  values: 
    - "$(params.enabled-platforms[*])"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

No branches or pull requests

3 participants