I am working with gitlab version 14.10.5.
In the left panel, there is a "Deployments" icone that allow me to create environments. In a gitlab repository I want to set up pipeline for dev, stage and main branches relating to 3 environments.
In these environments, I want to setup specific variables that will chaneg over environments.
For example, I want the variable NINJA to be setup with the value:
So, in my.gitlab-ci.yml I have:
build-testing:
stage: build
script:
- echo "Hello team"
- echo "$NINJA"
environment:
name: testing
only:
refs:
- dev
build-staging:
stage: build
script:
- echo "Hello team"
- echo "$NINJA"
environment:
name: staging
only:
refs:
- stage
build-production:
stage: build
script:
- echo "Hello team"
- echo "$NINJA"
environment:
name: production
only:
refs:
- main
How to setup the variable NINJA in an environment, in gitlab?
You can set variable scope, so a variable with same name will return different values in in different envs.
See also: https://docs.gitlab.com/ee/ci/environments/#scope-environments-with-specs
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.