opendevstack / ods-pipeline

Alternative ODS CI/CD pipeline based on Tekton / OpenShift Pipelines
Apache License 2.0
13 stars 5 forks source link

Trigger `*` pattern only matches non-slash characters #691

Open michaelsauter opened 1 year ago

michaelsauter commented 1 year ago

path.Match does not match e.g. feature/foo when the pattern is just *. If users want to match strings with slashes, they must specify the pattern */* as well. For example, to match all branches, one must write branches: ["*", "*/*"]. This could trip up users who might expect * to match everything (as I just did).

Should we special-case "*" to be a catch-all? Or change the whole matching behaviour? Or leave as is?

This was detected as part of #690, which does nothing about it except calling it out in the docs.

henninggross commented 9 months ago

During some migration work, I have noticed that all config files were indeed using "*" instead of "*", "*/*" and my assumption is that the maintainers of those config files intended to match all branches (including feature/foo). To me it'd be more intuitive to make "*" a catch-all, even if it means special-casing it. It can easily be overlooked in the docs and cause confusion if pipelines are not triggered as one would expect when setting "*".

michaelsauter commented 9 months ago

I opened https://github.com/opendevstack/ods-pipeline/pull/745, which addresses this.

While reading the code I realised that another way to express "match all", that currently already exists, is to simply do not specify anything. Example:

pipelines:
- triggers:
  - branches: ["main"]
    params:
    - { name: start.artifact-source, value: "my-nexus-repo" }
    - { name: deploy.namespace, value: "prod-env" }
  tasks:
  - name: deploy
- triggers:
  - params:
    - { name: finish.artifact-target, value: "my-nexus-repo" }
    - { name: deploy.namespace, value: "prod-env" }
    - { name: deploy.diff-only, value: "true" }
  tasks:
  - name: build
  - name: package
  - name: deploy

The second pipeline will be triggered for any branch.

@henrjk @henninggross Let me know if you'd still would continue with PR #745 or not.