Gitlab-ci merge request tasks running for all commits to an active merge request - limit to only initial merge request

Problem to solve

I created a gitlab-ci task to send a Teams webhook when a merge request occurs. This is working as expected.

What I am trying to solve is for this message to send once on merge request creation and not run the pipeline and send a merge request message each time a subsequent commit is made to a branch with an active merge request.

Configuration

stages:
  - notify-teams-channel-merge-request

notify-teams-channel-merge-request:
  stage: notify-teams-channel-merge-request
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  script:
...script that sends the message...

Versions

Please select whether options apply, and add the version information.

  • [ x ] Self-managed