Using rule variables in runner tags with extends

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

I'm trying to use a variable to change the runner tag depending on the rules conditions. This works when the variable is defined in the same job as where it is used, but it will not work when the variable is set in a job that extends the job where the tags are set.

I have a CI defined like so:

.generate:
  image:
    name: $CI_REGISTRY/my/project:$RUNNER_IMAGE
    entrypoint: [""]
  stage: generate
  variables:
    RUNNER_TAG: unsafe
  script:
    - echo "cut for brevity"
  tags:
    - udo
    - $RUNNER_TAG

Generate Go:
  extends: .generate
  variables:
    GEN_LANG: go
  rules: &generateRules
  - if: $CI_COMMIT_TAG
    variables:
      RUNNER_IMAGE: $CI_COMMIT_REF_NAME
      RUNNER_TAG: protected
  - changes: *masterChanges
    variables:
      RUNNER_IMAGE: $CI_COMMIT_SHORT_SHA
  - changes:
      paths:
      - proto/**/*
      compare_to: refs/heads/master

When the pipeline runs for a tag, the RUNNER_IMAGE is correctly set to the tag, but the runner always runs on the unsafe tag instead of the protected tag.

Edited by 🤖 GitLab Bot 🤖