CI_MERGE_REQUEST_SOURCE_BRANCH_SHA does not seem to be available anymore in rules condition when pipeline execution policies are defined
Summary
The CI variable CI_MERGE_REQUEST_SOURCE_BRANCH_SHA
is not being correctly evaluated in a job's rule conditions for merged results pipelines which have pipeline execution policies configured.
The strategy used is override_project_ci
.
This issue appears to have started after migrating from the deprecated Compliance Pipelines feature to the new pipeline execution policies.
Steps to reproduce
Set up a project that uses pipeline execution policies. Include a CI file from another project like:
workflow:
rules:
- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_SHA
variables:
CI_APPLICATION_TAG: $CI_MERGE_REQUEST_SOURCE_BRANCH_SHA
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_MERGE_REQUEST_ID
variables:
CI_APPLICATION_TAG: $CI_COMMIT_SHA
prestage:
stage: .pre
script:
- echo "MR SOURCE BRANCH SHA is ${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA}"
- echo "COMMIT SHA is ${CI_COMMIT_SHA}"
- echo "Option is ${OPTIONS}"
rules:
- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_SHA
variables:
OPTIONS: --pre-release dev --build ${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA}
- if: $CI_MERGE_REQUEST_ID
variables:
OPTIONS: --pre-release dev --build ${CI_COMMIT_SHA}
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
In the included file notice the use of CI_MERGE_REQUEST_SOURCE_BRANCH_SHA
in job rule conditions.
Create a merge request and run a merged results pipeline.
During the workflow evaluation stage of the included job, the appropriate value seems to be populated (based on the job being activated). However, when the job is in the rules evaluation stage, the variable is not populated (the rule is skipped over).
Example Project
Will populate later
What is the current bug behavior?
The predefined variable is not being populated during the included job's rules evaluation when pipeline execution policies are defined.
The strategy used is override_project_ci
.
What is the expected correct behavior?
The predefined variable should be populated during the included job's rules evaluation when pipeline execution policies are defined.
Relevant logs and/or screenshots
Nothing yet.
Output of checks
This bug happens on GitLab.com.