Skip to content

Allow strings and nested arrays of strings for before/after script

What does this MR do and why?

This Merge Request fixes #20957 (closed)

Nested "!reference[xxxx, script]" work
Nested "!reference[xxxx, before_script]" don't work
Nested "!reference[xxxx, after_script]" don't work

Looking at "Commands" and "Scripts" history, I wasn't able to find the reason for having 2 different objects

Therefore:

  • "Scripts" are replaced by "Command"
  • Tests are updated to change error message or remove case which are now allowed

Screenshots or screen recordings

CI configuration

default:
  image: alpine

test1:
  before_script:
    - echo "test1 before_script"
  script:
    - echo "test1 script"
  after_script:
    - echo "test1 after_script"

test2:
  before_script:
    - !reference [test1, before_script]
    - echo "test2 before_script"
  script:
    - !reference [test1, script]
    - echo "test2 script"
  after_script:
    - !reference [test1, after_script]
    - echo "test2 after_script"

test3:
  before_script:
    - !reference [test2, before_script]
    - echo "test3 before_script"
  script:
    - !reference [test2, script]
    - echo "test3 script"
  after_script:
    - !reference [test2, after_script]
    - echo "test3 after_script"

Unpatched Gitlab:
https://gitlab.com/guillaume.chauvel/ci-before-after-script/-/blob/944af7a4379b24d1139c037fc03ce72a77c9c06f/.gitlab-ci.yml
This GitLab CI configuration is invalid: jobs:test3:before_script config should be an array containing strings and arrays of strings

Updated GDK:
Screenshot_2021-11-18_at_20-01-03_test3___860____Jobs___Flightjs_Flight

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

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

Edited by Furkan Ayhan

Merge request reports

Loading