Variable in child template not working in rules

Hello everyone,

we have a template which has jobs and every job triggers a template which runs tests for coverages and so on.

basically what we have not is the following:

.gitlab-ci.yml

prepareApi:
  stage: release
  variables:
    DOCKER_REPOSITORY: '....'
  rules:
    - if: $CI_COMMIT_TAG
      when: never
  trigger:
    include:
      - local: csharp.gitlab-ci.yml
    strategy: depend

csharp.gitlab-ci.yml

code_quality:
  stage: test
  script:
    - echo 'do stuff...'
  rules:
    - if: $NO_TEST_COVERAGE
      when: never
    - if: $CI_COMMIT_TAG
      when: never
    - if: $CI_COMMIT_REF_NAME
      when: on_success
  needs:
    - job: build:image

Note the variable $NO_TEST_COVERAGE.

When I run the pipeline manually and set the variable NO_TEST_COVERAGE with value to true, this job is still visible in the pipeline. Why is that?

Hi @danielgroh

From your snippets here, it’s not totally clear to me how that variable is created and stored. However, these docs will tell you how variables can be passed down to child pipelines, so hopefully you can find an answer there.

Hi @danielgroh

variables from parent pipeline are not automatically available in child pipelines. You need to define them in the trigger job variables like you have the DOCKER_REPOSITORY variable or use the dotenv file like described in the docs from @snim2