Skip to content

Nested variables for gitlab-runner - two level down

Issue faced by an existing GitLab customer:

Variables inside variables does not work two level down. For example below

variables:
  demo: $RUNNER1
  RUNNER1: $RUNNER1


stages:
  - build

buildjob1:
  stage: build
  script: 
    - echo "Runner tag"
  tags:
    - ${demo}

buildjob2:
  stage: build
  script: 
    - echo "Runner tag"
  tags:
    - ${RUNNER1}


buildjob3:
  stage: build
  script: 
    - echo $RUNNER1
    - echo $RUNNER2

Variables, RUNNER1 and RUNNER2 are defined at group level. When performed echo in buildjob3, it works fine. But at the tags level, it does not. Tag picks up on "demo" variable defined in global variable section (like buildjob1) or "RUNNER1" one level down (like buildjob2)