Draft: Add optional keyword to CI include statements
What does this MR do and why?
- Adds support for
include:optional
statements in CI configurations. When enabled, it will cause:- Included files (either hard-coded, or defined via variables) that do not exist will not cause the pipeline to fail linting.
- Those non-existent files will simply be ignored and the rest of the pipeline will execute normally.
- This is a non-breaking change as
optional
is defaultfalse
. Configuration authors must explicitly opt-in to this behaviour. - Updates the CI YAML documentation.
- Updates the canonical compliance pipeline example with this new change.
How to set up and validate locally
- Set up a new project, create a file called
.gitlab-ci.yml
. - Add this to the content of that file:
stages:
- build
hello:
stage: build
script: "echo hello world"
include:
project: "path_to_this_project"
file: "example.yaml"
optional: false # (Or leave this line out all together.)
- Attempt to run a pipeline. The linter should fail and the pipeline should not run.
- Update
optional
totrue
. Run another pipeline. - Check that the pipeline executes with the single
hello
job.
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 #349020 (closed)
Edited by Grzegorz Bizon