Skip to content

Support for stages to accept a nested array of strings

Suyash Chavan requested to merge suyash-chavan/gitlab:master into master

Problem

Issue: #331892 (closed).

Currently stages is defined as array of strings. Whenever we use reference or anchor in the stages, stages becomes a nested array of strings and produces error.

Reproducing the problem

Following is the content of .gitlab-ci.yml:

.build-stages:
  - cloud
  - client

stages:
  - prebuild 
  - !reference [.build-stages]
  - postbuild

server:
  stage: cloud
  tags:
    - linux
    - docker
  script:
    - echo "cloud"

binaries:
  stage: client
  tags:
    - linux
    - docker
  script:
    - echo "client"

Following is the full configuration:

---
".build-stages":
- cloud
- client
stages:
- ".pre"
- prebuild
- - cloud
  - client
- postbuild
- ".post"
server:
  stage: cloud
  tags:
  - linux
  - docker
  script:
  - echo "cloud"
binaries:
  stage: client
  tags:
  - linux
  - docker
  script:
  - echo "client"

You can see the produced configuration contains stages as nested array of string.

Error Screenshot

image

Solution:

Declare stages as nested array of strings with maximum depth as 10 and flatten it.

Edited by Furkan Ayhan

Merge request reports