If you pass a pipeline parameter to matrix.exclude
, it does not function properly.
Consider the following minimum example:
version: 2.1
parameters:
skip: { type: string, default: "test" }
workflows:
version: 2
infra:
jobs:
- test:
type: approval
- other:
type: approval
name: << matrix.name >>
matrix:
alias: the-matrix
parameters:
name: [test, other, thing]
exclude:
- name: test
- bug:
type: approval
requires: [test, other, thing]
In this case, Circle sees this config as valid, since the duplicate “test” job is removed by the matrix exclude.
Config file at .circleci/config.yml is valid.
If we replace the string "test"
with << pipeline.parameters.skip >>
(whose value is equal to test), I would expect the file to still be valid, since the duplicate test
job is being filtered out from the matrix by the exclude in the same way.
version: 2.1
parameters:
skip: { type: string, default: "test" }
workflows:
version: 2
infra:
jobs:
- test:
type: approval
- other:
type: approval
name: << matrix.name >>
matrix:
alias: the-matrix
parameters:
name: [test, other, thing]
exclude:
- name: << pipeline.parameters.skip >>
- bug:
type: approval
requires: [test, other, thing]
However, instead we now get:
Error: Job 'bug' requires 'test', which is the name of 2 other jobs in workflow 'infra'
You can give a job within a workflow an explicit name by adding a name key
Expected Behaviour
I would expect these two configs to be equivalent, and equally valid.
Related (similar issue but the other way around, where the matrix parameters are populated by pipeline parameters):
In both cases, it seems the pipeline parameters are simply not substituted when evaluating the matrix.