Skip to content

Update CI schema to support `!reference`"

What does this MR do and why?

Adds support for the custom yaml keyword !reference for variables, script and rules.

Screenshots or screen recordings

header header
Screen_Shot_2022-05-19_at_11.13.00_AM Screen_Shot_2022-05-19_at_11.14.19_AM

How to set up and validate locally

  1. Setup your yaml file to use !reference
.gen:
  script: echo I am from gen

.vars:
  variables: 
    URL: "http://my-url.internal"
    IMPORTANT_VAR: "the details"

.cond:
  script: echo hello
  rules:
    - if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ /^feature/
      when: manual
      allow_failure: true

build:
  stage: "build"
  script: !reference [.gen, script]

test:
  stage: "test"
  variables: !reference [.vars, variables]
  script: echo $IMPORTANT_VAR
  rules: !reference [.cond, rules]
  1. Make sure you don't see any linting error

MR acceptance checklist

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

relates to #348666 (closed)

Edited by Frédéric Caplette

Merge request reports