Rules:if with variable from outside (parent pipeline) does not work as expected

Hi,

I’m struggling with this little example and am hoping someone can tell me why this isn’t working (job is not created). And even better if someone can tell me how to implement this case with gitlab: each job will be activated if job specific variable exists. The variables (job-specific-variablename in the example) come through a parent pipeline.
I am using gilab version 14.4.

.test-rules-if-with-variable:
  rules:
    - if: '$test_variable == "test"'
    - when: never
  script:
    - env

test-rules-if-with-variable:
  extends: [ .test-rules-if-with-variable ]
  variables:
    test_variable: $job-specific-variablename

Thanks,
Torsten