I have a task (pushing deliverable to production server) in my .gitlab-ci.yml
which needs to be limited to branches "hotfix" and "release_candidate", which means branches which name contains one of those strings (we had "hotfix_2"
at some point, so strictly equal to one of those strings won't do).
I added the following rule:
rules:
- if: $CI_COMMIT_BRANCH =~ /-release_candidate-/ || $CI_COMMIT_BRANCH =~ /-hotfix-/
but I see now that I can't use my task on my "release_candidate" branch. It worked with a branch called "1283-pouvoir-pusher-en-prod-des-branches-autres-que-hotfix-et-release_candidate"
, which was associated to the merge-request containing all those changes.
I'm not really familiar with RE2 regular expression syntax and resources are not easy to find (I still don't get why they always start and finir with "/" in Gitlab, for example, as it doesn't seem to be part of the syntax), so I don't get what's the cause of the problem. What am I missing?
This should work for your scenario
rules:
- if: $CI_COMMIT_BRANCH =~ /release_candidate|hotfix/