Skip to content

Draft: Use text interpolation in Ci::Yaml::Loader

What does this MR do and why?

Use text interpolation in Ci::Yaml::Loader

This commit introduces text interpolation to CI YAML loading under a ci_text_interpolation feature flag. This form of interpolation should enable array and hash type inputs, fix existing bugs with input types, and be faster.

Relates to: #433002 (closed)

How to set up and validate locally

  1. 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"
  1. In the project's .gitlab-ci.yml, include included.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
  2. See that the configuration is valid. Save it and see that a pipeline is created as expected

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #433002 (closed)

Edited by Avielle Wolfe

Merge request reports