The idea and approach of gitversion is very appealing in order to get some streamlined semVer tooling, thx for working on it.
However I really had a very hard time getting gitversion to run on linux. As there seems no easy road to get a linux compatible binary I decided to head out for docker.
Currently there are >1000 tags for the official image on hub.docker.com. As there is no overview it's hard to spot the right one to choose (basicly there seem to be 4.0.1 as well as 5.0.0 images for my favorite debian flavor).
Now came the tricky part plumbing all the switches and commands... here are my findings:
docker image has an entrypoint and workdir set to "/app", for this reason you must use some positional or named argument to set the path to the repo (which must be mounted as volume to the container). Whatever I never could get the init command to work. This seems kind of anoying to me. This is what I now ended up with(works for me):
docker run --rm -ti --name="gitversion" --volume="$(pwd)/.:/repo" --entrypoint="dotnet" -w "/repo" gittools/gitversion:4.0.1-linux-debian-netcoreapp2.1 /app/GitVersion.dll XXX
XXX can be init, /output json or any of the other switches.
From my point of view it might make sense to adapt the image in that direction. The gitversion command should be run in a way that is bulletproof and does not rely on the current working directory. instead the working-dir in the image should be set to _/repo_, and make this the expected default path where the repo should be made available to docker via volume mount.
Other than that I had to dig the source to find out that /output buildserver needs some environment variable JENKINS_URL in order to produce some results.
Thx for your efforts
Hi. I use GitVersion through Docker like this:
export GITVERSION="gittools/gitversion:5.0.0-linux-debian-9-netcoreapp2.2"
docker pull $GITVERSION
docker run --rm --volume "$(pwd):/repo" $GITVERSION /repo -output json # Output the version variables as JSON to the console
export SEMVER=$(docker run --rm --volume "$(pwd):/repo" $GITVERSION /repo -output json -showvariable FullSemVer) # Store FullSemVer in the $SEMVER environment variable so it can be used later.
Hi. I use GitVersion through Docker like this:
thx for sharing. I am quite puzzled to see you using '-' as prefix for parameter/command. On documentation and in help I had only seen '/'.
I'll check wether this approach is usable inside jenkins pipeline docker steps
- is supported as an alternative to / since the latter is interpreted as a file path on Unix. The entire command line interface is in need of a rework with a more modern command-based and cross-platform approach, we just haven't had time to do it.
@asbjornu thx for your help/guidance, here is a PR to add a quick hint on the documentation
https://github.com/GitTools/GitVersion/pull/1722
The entire command line interface is in need of a rework with a more modern command-based and cross-platform approach, we just haven't had time to do it.
That's on my list after 5.0.0 version release
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.
Most helpful comment
Hi. I use GitVersion through Docker like this: