Home > Back-end >  Regex to filter branches prefixed as release/
Regex to filter branches prefixed as release/

Time:09-28

For a Gitlab job I need a regex that matches all branches starting with release/.

For example:

  1. release/1
  2. release/v1
  3. release/v1.1
  4. release/communityedition

My job rule that's not working is:

myjob:
  image: mycustomimage
  stage: mystage
  rules:
    - if: $CI_COMMIT_BRANCH == "master"
      when: never
    - if: $CI_COMMIT_BRANCH == "dev"
      when: never
    - if: $CI_COMMIT_BRANCH =~ /^release\/'

CodePudding user response:

Try changing /^release\/' into /^release\//'.

The \ escapes the near /, so you must add an additional trailing /.

  • Related