Fix matrix expressions not working with spec header
What does this MR do and why?
This MR fixes matrix expressions not working when the config contains a CI Header.
When a CI config includes a header, the YAML goes through the interpolation system which processes all $[[ ... ]] blocks. Previously, when it encountered matrix expressions like $[[ matrix.PROVIDER ]], it would fail with "unknown interpolation provided: matrix" because the interpolation system tried to evaluate them immediately.
Matrix expressions should not be evaluated during YAML interpolation - they need to be left as literal strings and processed later by the MatrixInterpolator in the Normalizer, which has access to actual matrix values for each parallelized job.
This change updates the interpolation Block class to skip evaluation for matrix expressions, keeping them as literal strings. The solution is extensible through SKIP_INTERPOLATION_CONTEXTS, allowing other contexts to be skipped in the future if needed.
Issue: Gitlab-CI: `needs:parallel:matrix` not working ... (#578853 - closed)
Changelog: fixed
Steps to reproduce
-
Create a new project
-
Add a
.gitlab-ci.ymlfile with the following content:spec: {} --- linux:build: script: echo "Building linux..." parallel: matrix: - PROVIDER: [aws] linux:test: script: echo "Testing linux..." parallel: matrix: - PROVIDER: [aws] needs: - job: linux:build parallel: matrix: - PROVIDER: ['$[[ matrix.PROVIDER ]]'] -
Run a pipeline
-
Before this fix: Pipeline fails with error:
unknown interpolation provided: 'matrix' in 'matrix.PROVIDER' -
After this fix: Pipeline runs successfully with proper 1:1 job dependencies