Problem with running GitVersion on Build Server through Cake
See original GitHub issueWhen running GitVersion using:
gitversion /output buildserver
the idea is that GitVersion will assert the semantic version of your git repository, and it will then create a number of Environment Variables, which can then be later used within your build script.
You can see GitVersion creating these environment variables in the log file here:
Now, before I started using Cake, I used psake, and when executing GitVersion (using the buildserver
flag) from my psake script, I was immediately able to consume the environment variables, as you can see here:
https://github.com/chocolatey/ChocolateyGUI/blob/develop/BuildScripts/default.ps1#L440
i.e. GitVersion is called here:
https://github.com/chocolatey/ChocolateyGUI/blob/develop/BuildScripts/default.ps1#L439
and the environment variables are immediately consumed. Now, this “magic” was made possible on AppVeyor thanks to some work that was done by @FeodorFitsner which allowed the psake (PowerShell) calling script to immediately “see” the environment variables created by GitVersion. i.e.
PowerShell -> GitVersion = works!
However, in the case of running GitVersion through Cake, we have:
PowerShell -> Cake -> GitVersion != works
So my question is, what needs to happen to allow this process to also work?
Is it a change to GitVersion? Is it a change to Cake? Is it a change to AppVeyor?
Is it not even possible?
There is a workaround, which is to call GitVersion twice. Once with the /output buildserver
flag, which normalizing the Git Repository, and sets build number, etc, and once without that flag, to simply return the version number, but that feels like a bit of a hack.
There is also an open issue on GitVersion to also return the JSON result, when running with the buildserver
flag, https://github.com/GitTools/GitVersion/issues/675, but not sure if this is going to get implemented or not.
Just wanted to put this out there to see what the thoughts were.
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (6 by maintainers)
The good news is that the next release of GitVersion will cache the version it calculates, so the second call will be almost instant.
This will be implemented here: https://github.com/cake-build/cake/issues/1128