In .gitlab-ci.yml I import several files, including templates.yml and staging-new.yml
templates.yml has templates for jobs used in many other places. A template there may look like this:
.build-image:
stage: Build
tags:
- $RUNNER_XLARGE
script:
- scripts/build_image.sh
In staging-new.yml I have a generic template for jobs in that environment:
.staging-new:
variables:
RUNNER_SMALL: worker-xsmall
RUNNER_XLARGE: worker-medium
RUNNER_4XLARGE: worker-large
tags:
- staging
only:
refs:
- branches
variables:
- $CI_COMMIT_REF_NAME == "test-new-runners"
In staging-new.yml I extend both templates to create a job definition:
'Build Image (Staging New)':
extends:
- .build-image
- .staging-new
The problem is, this job definition does not get all tags defined in all templates it extends, but only the tags from the last template in the list.
I tried to do this:
'Build Image (Staging New)':
extends:
- .build-image
- .staging-new
tags:
- !reference [.build-image, tags]
- !reference [.staging-new, tags]
But I get this error: This GitLab CI configuration is invalid: jobs:build image (staging new):tags config should be an array of strings.
If I look into the full configuration in the pipeline editor I see this:
Build Image (Staging New):
stage: Build
tags:
- - "$RUNNER_XLARGE"
- - staging
script:
- scripts/build_image.sh
variables:
RUNNER_SMALL: worker-xsmall
RUNNER_XLARGE: worker-medium
RUNNER_4XLARGE: worker-large
only:
refs:
- branches
variables:
- $CI_COMMIT_REF_NAME == "test-new-runners"
extends:
- ".build-image"
- ".staging-new"
If I remove the dashes in front of !reference then it fails harder (I can’t even generate the full configuration).
Our repos are hosted on gitlab.com but our runners are self-built, running in AWS.