Skip to content

Merge request pipeline does not accept CI variables from git push option

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

The merge request pipelines do not accept push options for CI/CD variables. This also makes the variable conditions in rules unusable.

Note: It is known that passing variables and CI.SKIP only work for Branch pipelines today. This request is to extend the behavior to merge request pipelines as well.

Steps to reproduce

  1. Create a pipeline using the following configuration:

    # .gitlab-ci.yml
    
    always_job:
      rules:
        - if: '$CI'
      script:
        - env | grep -E '^CI_(PIPELINE|JOB)_' | sort
        - echo "SKIP_MY_EXAMPLE_JOB = $SKIP_MY_EXAMPLE_JOB"
    
    my_example:
      rules:
        - if: '$SKIP_MY_EXAMPLE_JOB != "true"'
      script:
        - echo "SKIP_MY_EXAMPLE_JOB = $SKIP_MY_EXAMPLE_JOB"
  2. Create a test branch and add a dummy commit:

    git checkout -b test
    git commit --allow-empty --message='Test trigger pipeline'
  3. Push the test branch with a variable in a git push option:

    git push origin test --push-option=ci.variable=SKIP_MY_EXAMPLE_JOB=true
  4. Create a merge request for this branch

  5. Look at the pipeline page and notice the two pipelines where my_example job is absent in the branch pipeline, but not absent in the merge request pipeline. Also notice the SKIP_MY_EXAMPLE_JOB variable is empty in the merge request pipeline.

branch pipeline merge request pipeline
Screenshot_2022-09-10_at_15.25.17 Screenshot_2022-09-10_at_15.25.29
Screenshot_2022-09-10_at_15.30.02 Screenshot_2022-09-10_at_15.30.12

Example Project

https://gitlab.com/maikelv/test-push-option-variables-merge-request-pipeline-bug

What is the current bug behavior?

The CI push option variable SKIP_MY_EXAMPLE_JOB is not passed to the merge request pipeline:

image

What is the expected behavior?

The CI push option variable SKIP_MY_EXAMPLE_JOB also being passed to the merge request pipeline:

image
This is not an existing log, but a photoshopped screenshot to communicate the desired output

Output of checks

This bug happens on GitLab.com (currently v15.4.0-pre 48afc24c73f)

Potential workarounds

  • Some customers have found success using the CI_COMMIT_MESSAGE (forum post) and rules to skip CI with Merge Request pipelines but we know this is not a great solution.
Edited by 🤖 GitLab Bot 🤖