include:inputs not passed as expected when using wildcard path
Context
For easier maintenance, I have split the root pipeline file /.gitlab-ci.yml in smaller chunks. So they are all included, passing spec inputs through.
As Gitlab CI has a single pipeline for all workflows, I use spec inputs with rules to filter out jobs based on which workflows to run.
Implementation
In order to achieve this, I have this MCE:
/.gitlab-ci.yml
spec:
inputs:
workflow:
default: "none"
options:
- "none"
- "debug"
---
stages:
- test
include:
- local: ".gitlab-ci.d/*.yml"
inputs:
workflow: "$[[ inputs.workflow ]]"
variables:
DEBUG_WORKFLOW: "$[[ inputs.workflow ]]"
debug-witness:
stage: "test"
needs: []
rules:
- when: "always"
image: "alpine:latest"
script:
- "echo \"DEBUG_WORKFLOW='${DEBUG_WORKFLOW}'\""
- "echo \"DEBUG_WORKFLOW_DEPLOY='${DEBUG_WORKFLOW_DEPLOY}'\""
debug-input:
stage: "test"
needs: []
rules:
- if: "'$[[ inputs.workflow ]]' != 'none'"
image: "alpine:latest"
script:
- "echo \"DEBUG_WORKFLOW='${DEBUG_WORKFLOW}'\""
- "echo \"DEBUG_WORKFLOW_DEPLOY='${DEBUG_WORKFLOW_DEPLOY}'\""
debug-variable:
stage: "test"
needs: []
rules:
- if: "$DEBUG_WORKFLOW != 'none'"
image: "alpine:latest"
script:
- "echo \"DEBUG_WORKFLOW='${DEBUG_WORKFLOW}'\""
- "echo \"DEBUG_WORKFLOW_DEPLOY='${DEBUG_WORKFLOW_DEPLOY}'\""
/.gitlab-ci.d/deploy.yml
spec:
inputs:
workflow:
default: "none"
options:
- "none"
- "debug"
---
variables:
DEBUG_WORKFLOW_DEPLOY: "$[[ inputs.workflow ]]"
debug-deploy-input:
stage: "test"
needs: []
rules:
- if: "'$[[ inputs.workflow ]]' != 'none'"
image: "alpine:latest"
script:
- "echo \"DEBUG_WORKFLOW='${DEBUG_WORKFLOW}'\""
- "echo \"DEBUG_WORKFLOW_DEPLOY='${DEBUG_WORKFLOW_DEPLOY}'\""
debug-deploy-variable-global:
stage: "test"
needs: []
rules:
- if: "$DEBUG_WORKFLOW != 'none'"
image: "alpine:latest"
script:
- "echo \"DEBUG_WORKFLOW='${DEBUG_WORKFLOW}'\""
- "echo \"DEBUG_WORKFLOW_DEPLOY='${DEBUG_WORKFLOW_DEPLOY}'\""
debug-deploy-variable-local:
stage: "test"
needs: []
rules:
- if: "$DEBUG_WORKFLOW_DEPLOY != 'none'"
image: "alpine:latest"
script:
- "echo \"DEBUG_WORKFLOW='${DEBUG_WORKFLOW}'\""
- "echo \"DEBUG_WORKFLOW_DEPLOY='${DEBUG_WORKFLOW_DEPLOY}'\""
Actual
Here are the included and run jobs based on event:
- When pushing commit:
debug-witness
- On new pipeline with
workflow=debug:debug-deploy-variable-globaldebug-inputdebug-variabledebug-witness
Expected
If pushing commit works as expected. For pipeline created with workflow=debug, we expected the following additional jobs:
debug-deploy-inputdebug-deploy-variable-local
Edited by Logan MAUZAIZE