Hi, I am having trouble getting !reference
to work for extending tags across the same file and multiple files (via includes). Can someone please help me? TIA!
Problem to solve
Describe your question in as much detail as possible:
What I want to do:
- The tags should span multiple jobs
- Have multiple tags that don’t get overwritten
- Allow for a variable in the tags.
Error: jobs:tester:tags config should be an array of strings
OR, if I am able to run it (using extends) all the tags will not appear.
Steps to reproduce
Recreate a similar issue in a single gitlab-ci.yml for gitlab v15.11:
variables:
PRD: "prd123"
stages:
- build
.general_k8srunner_tags:
- 'bootstrapped_runner'
- 'gitlab-runner'
- 'kubernetes'
- '$PRD'
.k8_non_prod_us_eastern_1_tags:
- nonprod.us-eastern-1
tester:
stage: build
script:
- echo hello
tags:
- !reference [.general_k8srunner_tags]
- !reference [.k8_non_prod_us_eastern_1_tags]
- Tried to change how tags are called in the tester job.
- I tried specifying the reference object is a tag and made the tags in the hidden jobs part of the
tag
key.
See below:
variables:
PRD: "prd123"
stages:
- build
.general_k8srunner_tags:
tags:
- 'bootstrapped_runner'
- 'gitlab-runner'
- 'kubernetes'
- '$PRD'
.k8_non_prod_us_eastern_1_tags:
tags:
- nonprod.us-eastern-1
tester:
stage: build
script:
- echo hello
tags:
- !reference [.general_k8srunner_tags, tags]
- !reference [.k8_non_prod_us_eastern_1_tags, tags]
- Tried with a reference to a single hidden job tag (that works), and tried importing with extends (required to add a script to make it work, but if that script is over-written the tags are also removed). See below:
variables:
PRD: "prd123"
stages:
- build
.general_k8srunner_tags:
script:
- echo "hello world"
tags:
- 'bootstrapped_runner'
- 'gitlab-runner'
- 'kubernetes'
- '$PRD'
.k8_non_prod_us_eastern_1_tags:
- nonprod.us-east-1
tester:
stage: build
extends: [.general_k8srunner_tags]
script:
- echo "goodbye world"
tags: !reference [.k8_non_prod_us_eastern_1_tags]
Configuration
we are using 15.11, I am not sure if this is self-managed or not and any of the specific configuration.
Versions
15.11