Manual pipeline prefilled variables always load from the default branch and not the selected ref
Summary
When manually running a pipeline from the UI, the prefilled variables are fetched from the default branch, even when a different branch or tag is selected. This causes pipelines on feature branches or tags to start with variable values that don’t match the configuration in that ref. The correct values from the selected ref are only used if the user removes the variable first.
Related issue: #520211
Steps to reproduce
-
Create a project with the following
.gitlab-ci.ymlon the default branch.variables: TEXT: value: MAIN-VAR description: desc build: script: - echo "TEXT : ${TEXT}" -
Create a new branch
feature, and change the variable.variables: TEXT: value: FEATURE-VAR description: desc build: script: - echo "TEXT : ${TEXT}" -
Ensure variable overrides are enabled for the project:
Go to Settings → CI/CD → Variables → "Minimum role to use pipeline variables"
-
In the UI, manually start the pipeline:
Go to Build → Pipelines → New Pipeline, then select the
featurebranch at the top. -
Observe that the prefilled variable TEXT loads with the value "MAIN-VAR" from the default branch instead of "FEATURE-VAR".
-
Running the pipeline on the feature branch results in this variable being overridden with the incorrect value.
Example Project
What is the current bug behavior?
Prefilled variables always show the value from the default branch, regardless of which branch or tag is selected.
What is the expected correct behavior?
Prefilled variables should load the values defined in the selected branch or tag.
Relevant logs and/or screenshots
Output of checks
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)
Possible fixes
Patch release information for backports
If the bug fix needs to be backported in a patch release to a version under the maintenance policy, please follow the steps on the patch release runbook for GitLab engineers.
Refer to the internal "Release Information" dashboard for information about the next patch release, including the targeted versions, expected release date, and current status.
High-severity bug remediation
To remediate high-severity issues requiring an internal release for single-tenant SaaS instances, refer to the internal release process for engineers.
