Reputation: 363
I want to display values from an .sh file into .gitlab-ci.yml but I cannot find a solution.
PS: I don't want to use environment variables in the .yml file
My versions.sh file is the following :
export PROJECT_VERSION = 2.1.25
My .gitlab-ci.yml is the following :
before_script:
- ./versions.sh
my_build_job:
- script:
- 'echo "PROJECT_VERSION = $(PROJECT_VERSION)"'
Upvotes: 1
Views: 100
Reputation: 1324537
I understand you don't want to use environment variables in the .yml
file, but that version.sh script defines a variable.
To display it, the syntax would be:
- 'echo "PROJECT_VERSION = ${PROJECT_VERSION}"'
That is ${...}
, not $(...)
which executes a command in a subshell.
But, as discussed in gitlab-org/gitlab-foss
issue 27921, that will not work.
You would need to source your script, as suggested here:
my_build_job:
- script:
- source ./versions.sh
- 'echo "PROJECT_VERSION = $(PROJECT_VERSION)"'
Upvotes: 1