定义变量的方式:
- 在.gitlab-ci.yml文件中定义
- pipeline中预定义的变量
- 设置在项目中设置的变量
1、. gitlab-ci.yml 定义变量
variables:
DEPLOY_VARIABLE: "default-deploy"
job1:
variables:
DEPLOY_VARIABLE: "job1-default-deploy"
script:
- echo "Run script with $DEPLOY_VARIABLE as an argument"
job2:
script:
- echo "Run script with $DEPLOY_VARIABLE as an argument"
2、项目中添加变量
project>>settings>>”CI/CD”>>Variables>>”Expand”
3、CI/CD预定义的变量
4、把所有变量列出
job_name:
script:
- export