Please help fill in this template with all the details to help others help you more efficiently. Use formatting blocks for code, config, logs and ensure to remove sensitive data.
Problem to solve
I have three jobs in the same project job_one
job_two
and job_three
job_three
needs job_two
and job_two
needs job_one
. In job_one
I’m creating a dotenv variable with multiple env variables inside. My goal is to access these variables in both job_two
and job_three
.
job_one:
stage: .pre
script:
- echo GIT_USER_NAME=${GIT_USER_NAME:-devops-bot_$GROUP} >> build.env
- echo DESTINATION=${DESTINATION:-$REGISTRY_URL/$CI_PROJECT_PATH} >> build.env
artifacts:
reports:
dotenv: build.env
job_two:
stage: push
script:
- echo $GIT_USER_NAME
needs:
- job: job_one
artifacts: true
This works as expected. Now I tried to implement job_three
in different ways, none of them worked
First Try
job_three:
stage: deploy
script:
- echo $GIT_USER_NAME
needs:
- job: job_two
artifacts: true
Second Try
job_three:
stage: deploy
script:
- echo $GIT_USER_NAME
needs:
- job: job_one
artifacts: true
- job: job_two
In job_three
the output is always an empty string ‘’. Is there a possibility to achieve my goal? I would also not matter if I could do it in another way than artifacts as long as A) the variables can be “generated” through bash and B) the variables can be loaded for every job in the pipeline.
Thank you very much for your help