Field Note

GitLab CI/CD variable string interpolation expressions only cover a subset of BASH

bash gitlab string-interpolation
Posted on Thursday, March the 28th 2024
1 min read

E.g.

# .gitlab-ci.yaml
variables:
  THE_IMAGE_TAG: "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG:-${CI_COMMIT_SHA}}"

Will evaluate to, for example, yourdomain.gitlab.com: (an invalid tag) even though at least CI_COMMIT_SHA should be defined.

One solution for this problem is to perform the string interpolation in the script block where evaluation is done in the shell.

friedrichkurz.me

© 2025 Friedrich Kurz

Privacy Policy