How to except the branch in gitlab.ci?

Viewed 46

Ran into a problem in gitlab.ci. I have a main branch and a test branch. The remaining branches are release branches and serve as a workspace for developers. What needs to be written in gitlab.ci so that the build-to-dev and deploy-to-dev stages run on all branches except the test branch?

2 Answers

Besides the only/except Keyword, the rules keyword can also be used and offers additional functionality than only/except.

jobs:
  rules:
    - if: '$CI_COMMIT_BRANCH == main'
      when: never
  script:
    - echo hello

But only/expect cant be combined with rules on one job

Related