I have a template file which has few stages like:
template.yaml
stages:
- a2
- a3
Now, I have another file .gitlab-ci.yaml which should include stages from above template file, but also needs few more stages:
include:
- project: 'path to repo'
ref: main
file: "/template.yml"
stages:
- a1
job1:
stage: a1
job2:
stage: a2
I get the following error:
chosen stage does not exist; available stages are .pre, a1, .post
Is it possible to do something similar without making any changes in the template file ?
Gitlab does not support merging of arrays, likely since it would have no idea which order the merged array is supposed to be in: https://docs.gitlab.com/ee/ci/yaml/includes.html#override-included-configuration-arrays
Therefore, you just need to manually include the full contents of any arrays that you are redefining. For your example:
include:
- project: 'path to repo'
ref: main
file: "/template.yml"
stages:
- a1
- a2
- a3
job1:
stage: a1
job2:
stage: a2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With