Search code examples
gitlabgitlab-ci-runner

How to get gitlab-runner to work with wildcards branch names


gitlab-runner 13.10

I want to kick off a job if the release branch starts with the project name 'release/projectname-310221'. I have a gitlab runner working perfectly when I push to a named branch using the only: method

only:
  - release/projectname-310321

if I use just 'release' or a regex 'release/project-.*$' it doesn't work

Any ideas what I'm doing wrong?

thanks

Richard


Solution

  • Use rules instead of only and check $CI_COMMIT_REF_NAME :

    rules:
      - if: '$CI_COMMIT_REF_NAME =~ /^release\/project\-.*$/'