'Two pipeline running when get failed

i have written workflow rules as give below. it working fine but as soon as pipeline fails two failed pipelines run: one for merge and one for branch. as well as i am also trying to run pipeline for a branch only when it is tag (which is not mentioned below).i am using CI_COMMIT_TAG but still its not working. NOTE: I am using fast-forward merge for merge request

workflow:
  rules:
    - if: $FORCE == "true"
    - if: $CI_COMMIT_BEFORE_SHA == "0000000000000000000000000000000000000000"
      when: never
    - if: $CI_COMMIT_REF_NAME =~ /^.*-stable$/
      when: never
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      #when: never 
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_REF_NAME == "master"'
      when: never
    - when: always


Solution 1:[1]

Excerpt from workflow:rules Examples:

[A]ll of the rules can be when: never, with a final when: always rule. Pipelines that match the when: never rules do not run. All other pipeline types run. For example:

workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule"
      when: never
    - if: $CI_PIPELINE_SOURCE == "push"
      when: never
    - when: always

If you want to exclude certain conditions from triggering a pipeline, simply add more conditions with when: never. Explicitly stating when the pipeline should be run isn't necessary due to the final when: always condition. I believe you have multiple passing conditions causing multiple pipelines to be created.

workflow:
  rules:
    - if: $FORCE == "true" # <- remove this line
    - if: $CI_COMMIT_BEFORE_SHA == "0000000000000000000000000000000000000000"
      when: never
    - if: $CI_COMMIT_REF_NAME =~ /^.*-stable$/
      when: never
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      #when: never # <- uncomment or delete rule
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_REF_NAME == "master"' # <- unnecessary single quotes
      when: never
    - when: always

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 Richard