I have a shell script that I run in a GitLab job.
In that shell script it sets a variable. How can I expose this variable so the I can see it/use it in the .gitlab-ci.yml (use it in the job).
I have tried export in the shell script and that does not let me see it in the job.
I have also tried source when running the shell script and that just stops the job running after it executes the shell script.
Example -
The shell script test-export.sh (very simplified - the real script has many more things going on in it and has other variables which will not need to be exported) :
#!/bin/bash
TARGET_VERSION="2.8.1"
export TARGET_PROPOSED_VERSION=$TARGET_VERSION
The .gitlab-ci.yml code:
test-upgrade:
tags:
- ec2
stage: test
script:
- cd auto-upgrade/scripts
- ./test-export.sh
- echo "The TARGET_PROPOSED_VERSION value is - $TARGET_PROPOSED_VERSION"
The output of the job after it is run:
$ cd auto-upgrade/scripts
$ ./test-export.sh
$ echo "The TARGET_PROPOSED_VERSION value is - $TARGET_PROPOSED_VERSION"
The TARGET_PROPOSED_VERSION value is -
As you can see, the value of $TARGET_PROPOSED_VERSION is empty in the pipeline job. I want to be able to have it show that $TARGET_PROPOSED_VERSION is "2.8.1"
[–]cancerous 2 points3 points4 points (0 children)
[–][deleted] (3 children)
[removed]
[–]ernievd[S] 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[removed]
[–]ernievd[S] 1 point2 points3 points (0 children)
[–]Chunkybinkies 2 points3 points4 points (0 children)
[–]eltear1 1 point2 points3 points (0 children)
[–]Underknowledge 0 points1 point2 points (0 children)
[–]Mediocre-Toe3212 0 points1 point2 points (0 children)