Use text interpolation in CI YAML loader
What does this MR do and why?
This MR uses the new text interpolation flow to interpolate inputs in CI config. It introduces a ci_text_interpolation
feature flag to protect CI pipeline processing in case of unexpected errors in the text interpolation. Text interpolation will allow us to introduce array type inputs and use !reference
in interpolated CI configs.
How to set up and validate locally
- Run
Feature.enable(:ci_text_interpolation)
- In any project, create a file
included.yml
in the root directory. Give it this content:
spec:
inputs:
after_script:
allow_failure:
type: boolean
cleanup:
deploy_job_name:
parallel:
type: number
test_script_name:
---
.scripts:
rspec:
- echo "Runs rspec"
cleanup:
- echo "$[[ inputs.cleanup ]]"
test_job:
after_script: $[[ inputs.after_script ]]
parallel: $[[ inputs.parallel ]]
script: !reference [.scripts, "$[[ inputs.test_script_name ]]"]
$[[ inputs.deploy_job_name ]]:
allow_failure: $[[ inputs.allow_failure ]]
script: echo "deploy"
-
In the project's
.gitlab-ci.yml
, includeincluded.yml
like this:include: - local: included.yml inputs: after_script: "!reference [.scripts, cleanup]" allow_failure: true cleanup: Cleanup things deploy_job_name: inputs_deploy parallel: 8 test_script_name: rspec
-
See that the configuration is valid. Save it and see that a pipeline is created as expected
Related to #433002 (closed)
Edited by Avielle Wolfe