如何在 gitlab ci/cd 中 pipeline job 之间传递变量
pipeline 中不同 job 默认是无法传递变量的,但是我们可以通过 artifacts 功能实现传递,具体看实例
variables:
VARIABLES_FILE: ./variables.txt
image: busybox:1.28.4
stages:
- build
- test
job1:
stage: build
script:
- APP_VERSION='v1.0'
- echo "export APP_VERSION=${APP_VERSION}" >> $VARIABLES_FILE
artifacts:
paths:
- $VARIABLES_FILE
job2:
stage: test
script:
- source $VARIABLES_FILE
- echo $APP_VERSION
- 也可以使用 cache,但是不建议