Reputation: 33
I need to exclude branches with the names feature/ussues- from some steps. There is a regular expression, but when I set except,rule or only, either the job always was included, or was not included at all.
Initially I tried this using rules:
:
rules:
- if: $CI_COMMIT_BRANCH =~ '^feature\.*\/.*
when: never
I expected this to match on branches like feature/issues-70
, feature/issues-771
, etc.
Upvotes: 1
Views: 1463
Reputation: 40901
The regex rule you used is slightly off. First, you need surrounding /
for the regex pattern. Second, the \.
in the pattern will mean to match a literal .
character, which is not what you want, based on the branch names you expect to match. Lastly, you need a matching rule for the job to be created at all (the default case when your rule doesn't match).
This should match all the example branch names you provided:
rules:
- if: $CI_COMMIT_TAG
when: never # same as except: - tags
- if: $CI_COMMIT_BRANCH == "test"
when: never # same as except: - test
- if: $CI_COMMIT_BRANCH =~ /^feature\/.*/
when: never
- when: on_success # the default when the first rule doesn't match
Upvotes: 1