When I set an environment variable with scope review/*
it doesn’t get passed on to the CI jobs in the review
branches.
They are empty when I print them in my job.
Even when I change the scope to the specific environment review/debugging
, I still don’t get any variables.
Only when I change the scope to *
are they passed on.
This is happening for all my repos.
As I understand the expected behavior is for variables to be passed on to the environment defined in their scope.
GiLab: 15.11.2
Runner: 15.11.0
gitlab-ci.yml:
include:
template: Auto-DevOps.gitlab-ci.yml
debug:
stage: build
image: alpine:latest
script:
- echo "Environment ${CI_ENVIRONMENT_NAME}"
- echo "CODE_QUALITY_DISABLED ${CODE_QUALITY_DISABLED}"
- echo "ENVIRONMENT_NAME ${ENVIRONMENT_NAME}"
Scoped Environment variables, can be scoped to environment specific jobs in the pipeline. As a pipeline can consist of several steps (testing, staging, production), one pipeline is not in itself scoped, but rather the individual jobs.
This is the case for the Code Quality job. This isn’t scoped to a specific environment, so rather than disabling per environment, you have to disable for all environments (*
) as you write, in order for AutoDevOps to pick it up.
However, if you want to remove the Code Quality step as part of your AutoDevOps flow for review apps only, you could include the Code Quality job in your .gitlab-ci.yml
file manually, and add a rule that only runs the job on pipelines that are based on the master
branch (supposing the master branch is what goes in to production).
include:
- template: Jobs/Code-Quality.gitlab-ci.yml
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: on_success
1 Like