conditional job causes an unwanted and broken merge request pipeline

Summary

When a job contains rules, it will cause an merge pipeline to be spawned.

Steps to reproduce

  1. Create a repository with a .gitlab-ci.yml file:

    # build job creates artifact
    build:
      script:
        - echo "Jussomething" > artifact.txt
      artifacts:
        paths:
          - artifact.txt
    
    # deploy job uses artifact
    deploy:onmyserver:
      stage: deploy
      script:
        - cat artifact.txt
      rules:
        # Would normally be some TOKEN for authentification
        - if: $CI_COMMIT_REF_SLUG
  2. Push this to the default branch

  3. Make any simple change, push a new merge request:

    git push -o merge_request.create local HEAD:newbranch

Example Project

Reproduce Bug Unwanted Merge Pipeline.

What is the current bug behavior?

There will be 2 pipelines created for the merge request:

  1. One for the branch/push (which is okay)
  2. One detached merge request pipeline, which only runs the jobs that have a matched rule

What is the expected correct behavior?

From the documentation, as far as I understand it, only 1 pipeline should run.

Relevant logs and/or screenshots

Screenshot of pipelines

see the live variant here.

Output of checks

This bug happens on GitLab.com

Edited by Norbert Lange