'Workflow rules not working on Merge Request in Gitlab

I am trying to run the below script as gitlab-ci.yml but somehow I am not able to trigger the CICD pipeline with a merge request.

Steps I am following:

  1. Create a branch from feature/new and name it as feature/abc
  2. Make test changes to feature/abc
  3. Create Merge request with target branch as feature/new.
stages:          # List of stages for jobs, and their order of execution
  - deployment
  - testing

workflow:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "feature/new"'

deployment-dev: # This job runs in the deploy stage.
  stage: deployment
     
  image: google/cloud-sdk
  services:
    - docker:dind
  script:
    - echo hello

    
  environment:
    name: main/$CI_COMMIT_REF_NAME
  when: on_success
testing-dev:   # This job also runs in the test stage.
  stage: testing  
      
  image: google/cloud-sdk
  services:
    - docker:dind
  script:
    - echo testing in progress


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source