Merge request event is never triggered

I’m trying to get pipeline running when merge request is done. But the merge_request_event is not triggered:
The .gitlab-ci.yml is looking approximately like this:

stages:
- merge
- deploy

merge-job:
stage: merge
script:
- <run script>
rules:
- if: ‘$CI_PIPELINE_SOURCE == “merge_request_event”’
when: always

deploy-job:
stage: deploy
script:
- <run script>

The merge-job never runs (when a merge request is created). Only deploy-job runs.

Gitlab is of version 15.8.3 and version of gitlab-runner is 15.9.1.

Looks like in this documentation there is no when: always under the if: $CI_PIPELINE_SOURCE == “merge_request_event”

So your merge-job should look as such:

merge-job:
  stage: merge
  script:
    - <run script>
  rules:
    - if: $CI_PIPELINE_SOURCE == “merge_request_event”

Another means of doing this is by a declaring a workflow as such:

workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event" # creates a merge request pipeline
    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS 
      when: never # does not create branch pipelines if a merge request is open for that branch
    - if: $CI_COMMIT_BRANCH # if none of the above are true, create branch pipeline

This allows you to create and differentiate between merge request pipelines and branch pipelines. This also ensures you have access to these merge request pipelines specific predefined variables.

Hope this helps!

Thank you for the answer.
Workflow works but not when I use stage of some reason.