Skip to content

Array flattening does not work on stages (invalid but no error)

It is not possible to use reference/anchors/extend in stages.

Following is the validation error: This GitLab CI configuration is invalid: stages config should be an array of strings.

.build-stages:
  stages:
    - build-binary
    - build-deb
    - build-ova

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

dependency-scan:
  stage: prebuild
  script:
    - echo "dependency-scan"

ova-scan:
  stage: postbuild
  script:
    - echo "ova-scan"

Follow is the full configuration of above .gitlab-ci.yaml:

---
".build-stages":
  stages:
  - build-binary
  - build-deb
  - build-ova
stages:
- ".pre"
- prebuild
- - build-binary
  - build-deb
  - build-ova
- postbuild
- ".post"
dependency-scan:
  stage: prebuild
  script:
  - echo "dependency-scan"
ova-scan:
  stage: postbuild
  script:
  - echo "ova-scan"
Edited by Suyash Chavan