Is it possible to declare variables in a YAML file and to recover those variables in the .gitlab-ci.yml and use them in a matrix job?

My gitlab instance is running with the Community Edition 15.91.

I am configuring a Gitlab C/I that will trigger several child pipeline in other project.

Each one of the child project and pipeline needs two variables (foo and bar) and I want to trigger them in parrallel with a matrix job.

The number of child project and pipeline will change, and I want to keep the configuration simple; if a new project needs to be add I only want to add the two needed variables in a file and nothing else.

So, I imagined this configuration:

First the file where the variables will be stored:

# variables.yml
matrix_variables:
  - foo: "single value for foo"
  bar: "single value for bar"
  - foo: "another single value for foo"
  bar: "antoher single value for bar"

Then, the .gitlab-ci.yml:

# .gitlab-ci.yml
include:
 - local: variables.yml

stages:
 - example

example_job:
 stage: example
 script:
  - echo "foo is $foo"
  - echo "bar is $bar"
parallel:
 matrix:
  - extends: matrix_variables

But when pushing and run on my gitlab project, I get the following error labbeled with “YAML invalid” and “error”:

jobs matrix variables config should implement a script: or a trigger: keyword

Okay np, so I tried to add a dummy script keyword to my variables.yml and even inside the matrix job in the .gitlab-ci.yml but still the same error.

I suspect that my gitlab version does not allow me to use matrix this way, (even though the error message is weird) what do you think ?

My question is: Is what I am trying to achieve (meaning use an external file filled with variables in a matrix job inside the .gitlab-ci.yml) even possible, if yes, how ?