In Gitlab-CI, you can use
after_script to do some stuff after a job, what ever appends during the job.
But if you tried to share environment variables from your
script part (note : I talk about environment variables which are declared with
export in one of this section), you won't be able to access to them.
What cause the issue?
after_script execution, Gitlab will create a new shell instancce to execute it.
So all the temporary elements which are not shared accross multiple shell instances won't be accessible in
So to resolve it, you can just print the value of the desired environment variable in a file, then read this file in the
job: before_script: - export TEST="test" - echo $TEST > test after_script: - export TEST = $(cat test) - echo $TEST
- Gitlab : https://gitlab.com/
- Gitlab-CI - after_script : https://docs.gitlab.com/ee/ci/yaml/#after_script
I hope it will help you! 🍺
Top comments (0)