Prefilled variables on manual pipelines not working properly with include:rules:if
Summary
When working on Prefilled variables for manual pipelines, variables are not showing properly if exact matching is used in the include:rules:if criteria. For example, given the following if conditions, only one of them will work.
include:
- local: gitlab-configs/custom-inputs-nonprod.yml
rules:
#- if: $CI_COMMIT_BRANCH == "dev" # will not work
#- if: $CI_COMMIT_BRANCH =~ /^dev$/ # will not work
- if: $CI_COMMIT_BRANCH =~ /dev/ # will work
Steps to reproduce
- Create a project.
- Create
gitlab-configs/custom-inputs-nonprod.ymland set the following.
variables:
VARIABLE1:
value: "staging"
options:
- "production"
- "staging"
- "canary"
description: "The deployment target. Set to 'staging' by default."
VARIABLE2:
value: "alpha"
options:
- "alpha"
- "bravo"
- "charlie"
description: "The deployment area. Set to 'alpha' by default."
- Create a
.gitlab-ci.ymlwith the following settings.
include:
- local: gitlab-configs/custom-inputs-nonprod.yml
rules:
- if: $CI_COMMIT_BRANCH == "dev" # will not work
#- if: $CI_COMMIT_BRANCH =~ /^dev$/ # will not work
#- if: $CI_COMMIT_BRANCH =~ /dev/ # will work
stages: # List of stages for jobs, and their order of execution
- build
build-job: # This job runs in the build stage, which runs first.
stage: build
script:
- echo "Compiling the code..."
- echo "|${CI_COMMIT_BRANCH}|"
- Create a
devbranch and try manually running the pipeline. - Observe that the global variables expected to be prefilled are not visible.
Example Project
https://gitlab.com/kballon-bug-report/zd585383_prefill_variable_manual_pipeline
What is the current bug behavior?
Prefilled variables are not visible if using exact matching in include:rules:if
What is the expected correct behavior?
Prefilled variables are visible if using exact matching in include:rules:if
Relevant logs and/or screenshots
- Using exact matching
- if: $CI_COMMIT_BRANCH == "stage"and- if: $CI_COMMIT_BRANCH =~ /^stage$/were tested.
- Using regular expression
if: $CI_COMMIT_BRANCH =~ /dev/
Output of checks
This bug happens on GitLab.com
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)(we will only investigate if the tests are passing)

