Pipeline Execution Policy with override_project_ci changes variable precedence of included non-policy jobs
Summary
When including the project CI via an override_project_ci PEP, the variable precedence of project YAML jobs doesn't work as expected.
Steps to reproduce
- Create new project with this CI configuration:
project-job: variables: MY_VAR: "Project job variable value" script: - echo $MY_VAR - Add a variable
MY_VARwithProject configuration variable valuein the project settings - Set up a PEP with
override_project_ciand the following policy CI YAML:include: - project: $CI_PROJECT_PATH ref: $CI_COMMIT_SHA file: $CI_CONFIG_PATH override-job: script: - echo $MY_VAR - Run pipeline in project
- Observe
Project job variable valuein the output ofproject-job(unexpected behavior), butProject configuration variable valuein the output ofoverride-job - Disable the policy
- Run pipeline in project
- Observe
Project configuration variable valuein the output ofproject-job(expected behavior)
Example Project
Full reproduction in this group: https://gitlab.com/gl-demo-ultimate-mgrabowski/i-510867
What is the current bug behavior?
This job ignores the existence of the project-level variable and outputs the lower-precedence job-level variable value instead.
What is the expected correct behavior?
That job should output Project configuration variable value as project-level variables have higher precedence than job-level variables.
Relevant docs
Our docs say:
Variables can be shared with pipeline execution policies using group or project settings. If a variable is not defined in a pipeline execution policy, the value from group or project settings is applied. If the variable is defined in the pipeline execution policy, the group or project setting is overwritten. This behavior is independent from the pipeline execution policy strategy.
The policy YAML does not define MY_VAR, so the value from the project configuration should be used. It should not just happen for the policy jobs, but for the included jobs as well. (Just as it would behave when one would perform that include "normally".)
Output of checks
This bug happens on GitLab.com