Variable interpolation fails when component and consumer share variable names
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
When using GitLab CI/CD components, variable interpolation fails if a job in the component defines variables with names that match those in the consuming project CI configuration. This results in the raw variable syntax being output instead of the expected interpolated value.
Steps to reproduce
(See demo project at https://gitlab.com/ulisesf_ultimate_group/consumer-project)
- Create a component with the following configuration:
spec:
inputs:
input-var1:
type: string
default: "default-val1"
input-var2:
type: string
default: "default-val2"
---
Example Job:
stage: build
script:
- echo "input-var1 is $EXAMPLE_VAR1"
- echo "input-var2 is $EXAMPLE_VAR2"
variables:
EXAMPLE_VAR1: $[[ inputs.input-var1 ]]
EXAMPLE_VAR2: $[[ inputs.input-var2 ]]
- Create a consumer pipeline that includes the component:
variables:
EXAMPLE_VAR1: passed_val1
EXAMPLE_VAR2_NON_SHADOWED: passed-val2
include:
- component: 'gitlab.com/ulisesf_ultimate_group/testing-variables-components/foo@master'
inputs:
input-var1: "${EXAMPLE_VAR1}"
input-var2: "${EXAMPLE_VAR2_NON_SHADOWED}"
Example Project
What is the current bug behavior?
When a component defines variables that share names with variables in the consumer pipeline:
- Variable interpolation fails for the matching variable names
- The raw variable syntax (${VARIABLE_NAME}) appears in the output instead of the interpolated value
- Variables with unique names interpolate correctly
What is the expected correct behavior?
All variables should properly interpolate, regardless of whether their names match between the component and consumer pipeline.
Relevant logs and/or screenshots
Output of checks
This bug happens on GitLab.com
Possible fixes
Edited by 🤖 GitLab Bot 🤖