CICD pipeline _only_ runs for the master branch and never for other branches

I have setup a project with 4 protected branches (master, uat, test & dev) but can only get the pipeline runner to trigger on commits to the master branch!

It is very frustrating as it will not commence the pipeline for the other 3 branches!?!

If I comment out the “only: - master” entry the pipeline no longer runs - which matches my understanding in that the branch is no longer to be serviced by this job.

However it seems when commits to the other branches occur the pipeline job is not being evaluated at all?!? I can’t find any reference in the documentation that suggests a configuration change that would extend to CICD process to consider running.

Any suggestion on where to go next would be very much appreciated. Cheers, Frank.

stages:
  - publish
publish:
  stage: publish
  tags:
  - script
  only:
  - master
  - uat
  - test
  - dev
script:
  -- echo "Publishing ..."

You don’t have to, but you can use rules to do this:

stages:
  - publish

workflow:
  rules:
    - if: $CI_MERGE_REQUEST_ID
      when: never
    - if: $CI_COMMIT_TAG
      when: never
    - when: always

publish:
  stage: publish
  tags:
  - script
  rules:
  - if: '$CI_COMMIT_BRANCH == "master"'
    when: on_success
  - if: '$CI_COMMIT_BRANCH == "uat"'
    when: on_success
  - if: '$CI_COMMIT_BRANCH == "test"'
    when: on_success
  - if: '$CI_COMMIT_BRANCH == "dev"'
    when: on_success
  - when: never
script:
  - echo "Publishing ..."

Thanks for the tips … which I tried but didn’t achieve the outcome desired (however are in my bottom drawer for use one day)!

The solution now discovered is to have a discrete .gitlab-ci.yml file declared in each of the branches in order to get the pipeline to run. I had naively assumed the master .gitlab-ci.yml would apply to the (entire) project not just the branch that “owns” it. Silly me!

Naturally we now have to make sure any merging of the .gitlab-ci.yml files is prevented - otherwise the pipeline will go silent. I plan to make the .gitlab-ci.yml branch agnostic so that the master version can be used on any of the other branches.

Ah right, it hadn’t even occurred to me to ask if you had different configs on each branch! Glad you got it fixed.