Merge Request pipeline stuck at "Checking pipeline status." and no pipeline run

EDIT: My problem was related to using $CI_COMMIT_BRANCH in a MR. Still I believe the UX. for the "Checking pipeline status." could improve.

When opening a merge request changing the .gitlab-ci.yml file to add some rules, the pipeline area is stuck in "Checking pipeline status." image

I can reproduce this by adding rules to 2 different jobs in different stages:

removing the rules block from either elixir lint or elixir test jobs, the pipeline starts running again (I tried not using yaml anchors as well, but the problem happens when defining the rule inline as well).

  rules:
    *only-if-elixir-changes
---
stages:
  - lint
  - test

.only-if-elixir-changes: &only-if-elixir-changes
  - if: $CI_COMMIT_BRANCH
    when: on_success
    changes:
      compare_to: 'refs/heads/master'
      paths:
        - "ex/**/*"
        - ".gitlab-ci.yml"
        - ".devbox/**/*"
        - "devbox.*"

.only-if-yaml-changes: &only-if-yaml-changes
  - if: $CI_COMMIT_BRANCH
    when: on_success
    changes:
      compare_to: 'refs/heads/master'
      paths:
        - "**/*.yml"
        - "**/*.yaml"

workflow:
  rules:
    # only for merge requests or master branch
    - if: $CI_MERGE_REQUEST_ID
    - if: $CI_COMMIT_BRANCH == "master"

yaml lint:
  image: peterdavehello/yamllint:1.29.0
  stage: lint
  rules:
    *only-if-yaml-changes
  script:
    - yamllint -c yamllint.config .
  retry: 0

elixir lint:
  image: elixir:1.16.2
  stage: lint
  rules:
    *only-if-elixir-changes
  script:
    - cd ex
    - mix deps.get
    - mix format --check-formatted
    - mix compile --warnings-as-errors
  retry: 0

elixir test:
  image: elixir:1.16.2
  stage: test
  rules:
    *only-if-elixir-changes
  script:
    - cd ex
    - mix deps.get
    - mix test
  retry: 0
Edited by Victor van Herpt