I am working with GitLab 14.6.2-ee.
I am trying to use the YAML reference feature to re-use code snippets in my GitLab configuration files. I've boiled it down to what I think is the simplest use case, but cannot get the file to validate.
.gitlab-ci.yaml:
...
.hidden:
.update-static-site:
rules:
if: $CI_COMMIT_BRANCH =~ /(^develop$|^master$|^staging-.*)/
...
trigger-downstream-pipeline:
stage: .post
trigger:
project: project-x/project-x-manifest
branch: master
variables:
SOURCE_COMMIT_SHA: $CI_COMMIT_SHA
SOURCE_COMMIT_REF_NAME: $CI_COMMIT_REF_NAME
APP_NAME: project-x
needs:
- job: push-project-x-to-harbor
artifacts: false
rules:
- !reference [.hidden, .update-static-site, rules]
I cannot get the !reference
line to validate. I keep getting Unresolved tag: !reference
.
I found a SO posting (GitLab CI - Reuse rules with !reference tag) that addresses exactly what I'm trying to do, but it does not work.
rules: !reference [.hidden, .update-static-site, rules]
and see if that works? i.e. not a list, but a single value forrules:
– Surfacetoairrules:
statement as well as indented on the next line. – Hypsopush-project-x-to-harbor
exists). Are you sure you've provided a reproducible example? Maybe there's a problem lost in translation here that's not in the question. I don't think it's a GitLab version issue since this feature doesn't have any change notes for newer versions, but that may be a possibility. – Araucaria