Reference variables from multiple jobs

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

Starting with GitLab 13.9, the !reference tag can be used:

.setup:
  variables:
    key1: val1
    key2: val2

my-job:
  variables: !reference [.setup, variables]
  script:
    - echo hello

But what if you want to reference variables from multiple jobs?
This does not seem to be possible, since variables are not defined as a list. The following is not validated by the CI lint and will fail:

.setup:
  variables:
    key1: val1
    key2: val2

.setup2:
  variables:
    key3: val3
    key4: val4

my-job:
  variables:
    !reference [.setup, variables]
    !reference [.setup2, variables]
  script:
    - echo hello

I've tried multiple variations of the above with different syntax but to no avail. I also cannot find any examples or docs where variables in one job can reference other variables from multiple jobs. This leads me to believe there has been an oversight in the design of the !reference implementation. It would be super useful to be able to reference variables from multiple jobs.

Edited by 🤖 GitLab Bot 🤖