Skip to content
Snippets Groups Projects

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
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • added 1 commit

    • acb3ed22 - Set CI Config Entry 'Script' similar to 'Commands'

    Compare with previous version

  • Guillaume CHAUVEL added 120 commits

    added 120 commits

    Compare with previous version

  • Guillaume CHAUVEL changed the description

    changed the description

  • Markus Koller changed milestone to %14.6

    changed milestone to %14.6

  • Guillaume CHAUVEL added 153 commits

    added 153 commits

    • 4ca25682...c867a760 - 152 commits from branch gitlab-org:master
    • fdcb770d - Change Gitlab::Ci::Config::Entry 'Script' content equals to 'Commands'

    Compare with previous version

  • Guillaume CHAUVEL resolved all threads

    resolved all threads

  • Guillaume CHAUVEL changed the description

    changed the description

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading