Fix file variable expansion in downstream pipelines
Part 3 of #390252 (closed)
What does this MR do and why?
- Prevent file variable expansion content in downstream pipeline variables.
- Implicitly forwards file variable dependencies as file type to downstream pipelines when they are interpolated in a variable. This will ensure that the downstream pipeline has the file variable in the file system.
MR dependencies:
-
!121215 (merged) - adds a keyword argument to
ExpandVariables
to choose between expanding file variables or not. -
!124580 (merged) - refactors downstream variables in
Ci::Bridge
.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After | |
---|---|---|
Child pipeline | ||
Multi-project pipeline | Note that the file variable is created in the downstream project path: |
How to set up and validate locally
- Create a group
test-group
. - Create 2 projects
test-group/main-project
andtest-group/downstream-project
- In
test-group
, create a File variableGROUP_FILE_VARIABLE
. - In
test-group/main-project
, create a File variablePROJECT_FILE_VARIABLE
. - In
test-group/main-project
, create the following CI YMLs for the parent pipeline and child pipeline. - In
test-group/downstream-project
, create the following CI yml - Run pipeline manually on
test-group/main-project
, specifying a File variabelPIPELINE_FILE_VARIABLE
. - Observe the results of the
echo
jobs - Enable feature flag
:ci_prevent_file_var_expansion_downstream_pipeline
- Repeat steps to run pipeline manually
- Observe the results of the
echo
jobs
main-project CI YMLs
# .gitlab-ci.yml
variables:
GROUP_FILE_VARIABLE: "$GROUP_FILE_VARIABLE"
PROJECT_FILE_VARIABLE: "$PROJECT_FILE_VARIABLE"
PIPELINE_FILE_VARIABLE: "$PIPELINE_FILE_VARIABLE"
echo:
script:
- echo "GROUP_FILE_VARIABLE $GROUP_FILE_VARIABLE"
- echo "PROJECT_FILE_VARIABLE $PROJECT_FILE_VARIABLE"
- echo "PIPELINE_FILE_VARIABLE $PIPELINE_FILE_VARIABLE"
trigger_child:
trigger:
include:
- local: child-pipeline.yml
trigger_downstream_project:
trigger:
project: test-group/downstream-project
# child-pipeline.yml
echo:
script:
- echo "GROUP_FILE_VARIABLE $GROUP_FILE_VARIABLE"
- echo "PROJECT_FILE_VARIABLE $PROJECT_FILE_VARIABLE"
- echo "PIPELINE_FILE_VARIABLE $PIPELINE_FILE_VARIABLE"
downstream-project CI yml
echo:
script:
- echo "GROUP_FILE_VARIABLE $GROUP_FILE_VARIABLE"
- echo "PROJECT_FILE_VARIABLE $PROJECT_FILE_VARIABLE"
- echo "PIPELINE_FILE_VARIABLE $PIPELINE_FILE_VARIABLE"
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #390252 (closed)
Edited by Albert