Extended Jobs don't override CI/CD values

Hey all, am I missing something about variables set in extended jobs? I’m trying to reuse a job but change some of the variables, but if the original variables are defined in CI/CD then they don’t get replaced. I’ve recreated the issue in this project, it should be set to public deploy_dr (#2594443421) · Jobs · myarbrou / cicd-test · GitLab

Steps to reproduce:

In a project under Settings > CI/CD > Variables add a new value named MIKES_TEST_VALUE with the value !!! I should NOT see this value echoed in the dr job !!!

Create a gitlab-ci.yaml with the contents


deploy_prod:
  rules:
    - when: never
  script:
    - echo $MIKES_TEST_VALUE
    - echo $SECOND_TEST_VALUE

deploy_dr:
  rules:
    - when: always
  extends: deploy_prod
  variables:
    MIKES_TEST_VALUE: 'The correct DR value'
    SECOND_TEST_VALUE: 'The correct second DR value'

Observe the job that gets created called deploy_dr which prints the incorrect value in the log
The expected result being that the exteded job should override MIKES_TEST_VALUE with the value The correct DR value

Actually I see the precedence is that job variables are overridden by project variables

I see that I can override those variables by running a pipeline manually, but is there a way to have a job replace the project level variables automatically?

Gitlab CI UX is unbelievably idiotic. I do not know why everyone rates it so highly. It behaves in completely unexpected ways, and usually the opposite of conventional software wisdom.

Here’s a great example of its confusing behaviour.

Suppose you set: GIT_STRATEGY: fetch globally for your project, which could be a monorepo. For a specific pipeline, however, you want more control over what files you want to checkout, so you’d like the jobs in that pipeline to run with GIT_STRATEGY: none.

Turns out there is no way to do this. The globally defined variables will override the job-level or even file-level variables. Whereas in every object-oriented programming language or similar project organization, local overrides global.

Gitlab CI is BAD.