Gitlab MR Decoration with Rules instead of Only

  • CI system used: Gitlab
  • Languages of the repository: Java and Python

In order to get merge request decoration working, is it necessary to use the tag:

only:
- merge_requests

In the YML file, or are you able to use an equivalent rule to trigger it? I’ve tested some rules like

rules:
- if: $CI_MERGE_REQUEST_ID == null

but haven’t been able to get it working without the only: -merge requests.

1 Like

You have to configure your pipeline to run on MR and not on pushing to feature branches. Having this at the top of my .gitlab-ci.yml file did the trick for me:

workflow:
  rules:
    - if: $CI_MERGE_REQUEST_IID
    - if: $CI_COMMIT_TAG
    - if: '$CI_COMMIT_BRANCH == "master"'
    - if: '$CI_COMMIT_BRANCH == "devel"'

See also: https://docs.gitlab.com/ee/ci/merge_request_pipelines/#use-rules-to-run-pipelines-for-merge-requests

2 Likes

Thank you! This was the issue, we had been using feature branches due to this bug https://gitlab.com/gitlab-org/gitlab/-/issues/33694

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.