Good Morning,
I am having trouble getting GitVersion to run using CakeBuild and the GitVersion.CommandLine tool in a Docker container on my build environment servers (which are Windows 2016 Standard). When the target task is executed that contains the GitVersion method I get the exception below:
``c#
Cake.Core.CakeException: GitVersion: Process returned an error (exit code 1).
at Cake.Core.Tooling.Tool1.ProcessExitCode(Int32 exitCode) in
C:\projectscake\src\Cake.Core\Tooling\Tool.cs:line 139
at Cake.Core.Tooling.Tool1.Run(TSettings settings, ProcessArgumentBuilder arguments,
ProcessSettings processSettings
, Action1 postAction) in C:\projectscake\src\Cake.Core\Tooling\Tool.cs:line 119
at Cake.Common.Tools.GitVersion.GitVersionRunner.Run(GitVersionSettings settings) in
C:\projectscake\src\Cake.Common
\Tools\GitVersion\GitVersionRunner.cs:line 61
at Submission#0.GitVersion(GitVersionSettings settings)
at Submission#0.<
at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass8_0.
C:\projectscake\src\Cake.C
ore\CakeTaskBuilderExtensions.cs:line 185
at Cake.Core.ActionTask.
C:\projectscake\src\Cake.CoreActionTask.cs:line 100
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
at Cake.Core.DefaultExecutionStrategy.
C:\projectscake\src\Cake.Core\DefaultExecutio
nStrategy.cs:line 87
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
at Cake.Core.CakeEngine.
C:\projectscake\src\Cake.Core\CakeEngine.cs:line 243
The strange part however is that I can run the same task on the host and the script is perfectly able to generate the version information. Im not sure what is special about this container that it would not work. Even stranger still is that the same image built and run on my development machine has GitVersion working fine. Development machine is Windows 10 with beta channel docker though.
For what its worth. this is the docker file Im using.
```dockerfile
# escape=`
FROM microsoft/dotnet-framework-build
WORKDIR /build
SHELL ["powershell.exe", "-ExecutionPolicy", "Bypass", "-Command"]
ENV JRE_DOWNLOAD_URL http://javadl.oracle.com/webapps/download/AutoDL?BundleId=210185
ENV JRE_DOWNLOAD_SHA 9E9EC54B09F738BBD7FD911E11D164D22FB08E05A3A9C6251DD64CFCDAC229CBA076405D29B81C99C813C58DF22FCE48C0FD16EC4C2D5E20F6D174AC983CC2E8
RUN Invoke-WebRequest $Env:JRE_DOWNLOAD_URL -OutFile jre.exe; `
if ((Get-FileHash jre.exe -Algorithm SHA512).Hash -ne $Env:JRE_DOWNLOAD_SHA) { `
Write-Host 'CHECKSUM VERIFICATION FAILED!'; `
exit 1; `
}; `
Start-Process -FilePath jre.exe -PassThru -Wait -ArgumentList "/s,INSTALLDIR=c:\Java\jre1.8.0_91,/L,install64.log"; `
Remove-Item -Force jre.exe; `
[Environment]::SetEnvironmentVariable('"Path"', $Env:Path + '";C:\Java\jre1.8.0_91\bin"', [EnvironmentVariableTarget]::Machine)
CMD powershell.exe ./build.ps1
and the CakeBuild bits look like.
```c#
...
...
// Global access for various tasks
GitVersion gitVersion = null;
...
Task("PopulateVersion")
.Does(() =>{
gitVersion = GitVersion(new GitVersionSettings
{
UpdateAssemblyInfo = false
});
Information("Current Version: {0}", gitVersion.SemVer);
});
...
```
I would be very grateful for any assistance on where I should look to investigate why this exception is being thrown under these circumstances.
Due to #983 not being implemented yet, you actually need to run GitVersion twice in Cake to get it to both populate the build server with its version variables as well as provide a return value. Try this:
```c#
// Will just set the version number of the build in the build server to the FullSemVer.
GitVersion(new GitVersionSettings
{
Output = GitVersionOutput.BuildServer
});
// Will just return the version number variables as JSON, which will be parsed by the Cake alias and then returned.
gitVersion = GitVersion(new GitVersionSettings
{
Output = GitVersionOutput.Json
});
```
Facing the same issue currently when trying to run this in Docker (Alpine Linux):

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.
Ran into this issue today
19:43:18 Cake.Core.CakeException: GitVersion: Process returned an error (exit code 1).
19:43:18 at Cake.Core.Tooling.Tool`1.ProcessExitCode(Int32 exitCode) in C:\projects\cake\src\Cake.Core\Tooling\Tool.cs:line 139
19:43:18 at Cake.Core.Tooling.Tool`1.Run(TSettings settings, ProcessArgumentBuilder arguments, ProcessSettings processSettings, Action`1 postAction) in C:\projects\cake\src\Cake.Core\Tooling\Tool.cs:line 119
19:43:18 at Cake.Common.Tools.GitVersion.GitVersionRunner.Run(GitVersionSettings settings) in C:\projects\cake\src\Cake.Common\Tools\GitVersion\GitVersionRunner.cs:line 61
19:43:18 at Submission#0.VersionInfo.LoadFromGitVersion(ICakeContext context)
19:43:18 at Submission#0.VersionInfo..ctor(ICakeContext context, String versionFormat, Int32
Most helpful comment
Facing the same issue currently when trying to run this in Docker (Alpine Linux):