[Question] How to access variables from Gitlab CI? #2988
Replies: 8 comments
-
The variables should be available as |
Beta Was this translation helpful? Give feedback.
-
Thanks for getting back! Your help is appreciated :) I tried that previously but it didn't seem to find any values there. I would expect the echo to output a variable. |
Beta Was this translation helpful? Give feedback.
-
Maybe my Dockerfile is wrong?
|
Beta Was this translation helpful? Give feedback.
-
Running |
Beta Was this translation helpful? Give feedback.
-
I'm having the same problem in GitLab CI. I don't see how the |
Beta Was this translation helpful? Give feedback.
-
Adding |
Beta Was this translation helpful? Give feedback.
-
The way I solved this is based on https://stackoverflow.com/a/59686463/318317 I run the gitversion docker container in my gitlab ci script, and capture the output. In my case, I only want a single variable (FullSemVer), so I directly set the environment variable: script:
- GitVersion_FullSemVer=$(docker run --rm -v "$(pwd):/repo" gittools/gitversion:5.6.10 /repo /output json /showvariable FullSemVer)
- echo "${GitVersion_FullSemVer}" As an alternative, if you need more variables, you could save the output to a file and parse it later: script:
- docker run --rm -v "$(pwd):/repo" gittools/gitversion:5.6.10 /repo /output json > version,json
- cat version.json |
Beta Was this translation helpful? Give feedback.
-
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions. |
Beta Was this translation helpful? Give feedback.
-
I am building my asp.net core project in Gitlab CI and Docker using Gitversion as an MSBuild task. I can't seem to find the correct environment variable to access the version within the Gitlab pipeline. Any help would be much appreciated :)
This should be tagged as a question but I can't quite figure out how to do that, sorry :(
Beta Was this translation helpful? Give feedback.
All reactions