Understanding $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH and when it runs

I’m currently trying to understand when a rule like if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH would run a pipeline using workflow block

I have seen a few times this week when I do commits on my default branch main and then push them it doesn’t run anything at all, but when I do a single commit and push it will run.

The other day I had the following:

  • commit 1 main
  • commit 2 main
  • commit 3 main
  • push → main
  • no pipeline
  • commit 4
  • push → main
  • pipeline

We even had it when a merge request was merged it just didn’t run any jobs or create the pipeline as it normally would and we do a lot of merge requests over the day.

Am I misunderstanding the CI_COMMIT_BRANCH in my workflows check here?

Gitlab workflow config is below. Note: None of the jobs have rules blocks only the workflow has rules which I assume means all jobs should run?

Configuration

workflow:
  name: $PIPELINE_NAME
  rules:
    - if: $CI_MERGE_REQUEST_IID
      variables:
        PIPELINE_NAME: "MR - ${CI_MERGE_REQUEST_TITLE}"
    - if: '$CI_PIPELINE_SOURCE == "web"'
      variables:
        PIPELINE_NAME: "Manual Pipeline"
      when: never 
    - if: $CI_COMMIT_TAG
      variables:
        PIPELINE_NAME: "Tag${CI_COMMIT_TAG} - ${CI_COMMIT_TAG_MESSAGE}"
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      variables:
        PIPELINE_NAME: "Main Pipeline - ${CI_COMMIT_MESSAGE}"


Versions

  • GitLab.com SaaS