Merge event pipeline not being respected ('$CI_PIPELINE_SOURCE != "merge_request_event"')

I have the following rules on my job:

rules:
    - if: '$CI_PIPELINE_SOURCE != "merge_request_event"'
    - if: '$CI_COMMIT_BRANCH != "build_cicd_image"'
    - if: '$CI_COMMIT_BRANCH != "main"'

It still runs a pipeline for merge request events. Why? What am I doing wrong?

@doublethink I think instead of != try the following:

rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
      when: never

I hope this helps!

-James H, GitLab Product Manager, Verify:Pipeline Execution

I’ve tried that as well, but it still creating two pipelines.

Let me know if I can provide more information :slight_smile:

@doublethink I’d give the docs about duplicate pipelines a read and see if it helps.

-James H, GitLab Product Manager, Verify:Pipeline Execution

1 Like

@jheimbuck_gl thanks! The docs helped indeed.

This is working for me now:

workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
      when: never
    - if: $CI_COMMIT_TAG
    - if: $CI_COMMIT_BRANCH
1 Like