[英]Gitlab CI/CD: Setup variables relating to environment
I am working with gitlab version 14.10.5.我正在使用 gitlab 版本 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.在 gitlab 存储库中,我想为与 3 个环境相关的开发、阶段和主要分支设置管道。
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:例如,我希望使用以下值设置变量 NINJA :
So, in my.gitlab-ci.yml I have:所以,在 my.gitlab-ci.yml 我有:
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?如何在环境中设置变量NINJA ,在 gitlab 中?
You can set variable scope, so a variable with same name will return different values in in different envs.您可以设置变量 scope,因此具有相同名称的变量将在不同的环境中返回不同的值。
See also: https://docs.gitlab.com/ee/ci/environments/#scope-environments-with-specs另请参阅: https://docs.gitlab.com/ee/ci/environments/#scope-environments-with-specs
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.