Variables are not passed to extends function via rules

Hi,
having following issue
i have pipeline on gitlab.com

.build and deploy:
  stage: deploy
  image: dockerimage
  before_script:
    - pip install -r requirements.txt
  script:
    - echo "$account_id"
  tags:
    - test-${account_type}

stages:
  - deploy

deploy:
  extends: .build and deploy
  rules:
    - if: $CI_COMMIT_BRANCH
      variables:
        account_type: "type1"
        account_id: "44444444"
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      variables:
        account_type: "type2"
        account_id: "555555555"

so the result - it tries to run job on test-${account_type} runner
it does not substitute the placeholder

what was tried:
tags:
- “test-${account_type}”

tags:
- test-$account_type

tags:
- “test-$account_type”

but the following construction works as expected

.build and deploy:
  stage: deploy
  image: dockerimage
  before_script:
    - pip install -r requirements.txt
  script:
    - echo "$account_id"
  tags:
    - test-${account_type}

stages:
  - build

type1 deploy:
  extends: .build and deploy
  variables:
    account_type: type1
    account_id: 44444444
  rules:
    - if: $CI_COMMIT_BRANCH
      when: always

type2 deploy:
  extends: .build and deploy
  variables:
    account_type: type2
    account_id: 555555555
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      when: always
1 Like