Skip to content

Allow default value for variables

Description

Allow variables defined global or on job level to have a default value as for example:

${CI_REGISTRY_IMAGE:-registry.somehost.com/namespace/project}:tag

This would allow people to fork a project and enable their own CI_REGISTRY and propose new Docker images and/or a new Dockerfile. But for people which do not enable their registry, using $CI_REGISTRY_IMAGE will be an empty string, so in merge requests the build will always fail.

Proposal

Example .gitlab-ci.yml:

build:
  image: ${CI_REGISTRY_IMAGE:-registry.gitlab.com/daniel.widerin/testproject}:build
  script:
    - echo "run fancy stuff..."