GitVersion: Unable to use gitversion as part of AppVeyor build
Description
I am unable to use Gitversion as part of my build to version my application. What are the recommendation to use gitversion as part of AppVeyor build to version .NET application?
Steps
At the beginning of the build, AppVeyor clones the repository and checkouts out the commit meant to be built:
git clone -q --branch=[my branch] https://[my repo].git C:\projects\[...]
git checkout -qf [commit to build]
But when Gitversion runs I see the following error:
INFO [09/17/18 9:35:55:42] Running against branch: (no branch) ([commit to build])
WARN [09/17/18 9:35:55:42] An error occurred:
It looks like the branch being examined is a detached Head pointing to commit '[commit]'. Without a proper branch name GitVersion cannot determine the build version.
I tried then using dynamic repository but it wouldn’t checkout the branch on the right commit, for example:
gitversion /url [url] /b test-gitversion /c 68264bd15c7364c3f3e53c764260776d4706d288
---
* 317aab8 (origin/test-gitversion, test-gitversion) removed another comment
* 68264bd (HEAD) removed comment
* 1570202 (tag: 1.15.5-alpha.1) Try to resolve first variable from local repository before trying dynamic.
* f77f974 (origin/master, origin/HEAD, master) removed more
It would checkout test-branch
on the same level as master
branch f77f974
and not 68264bd
.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 32 (15 by maintainers)
I’ve experienced the same thing with GitVersion 4.0 on both TeamCity as well as AppVeyor. For TC, I managed to get it to work by using the
teamcity.git.fetchAllHeads=true
option. However, there does not seem to be a workaround for AppVeyor. I had to manually build the latest version of Fluent Assertions and push it to NuGet.In all scenarios, it looks like it is indeed caused by building a tag from a branch that already has successive commits as explained by @Kimserey in https://github.com/GitTools/GitVersion/issues/1477#issuecomment-445166023.
The same problem did not happen with GitVersion 3.x.
Odd. I have used gitversion with appveyor in various projects and not needed any additional git checkout commands.
For example, I use it here in DotNet.Glob: https://ci.appveyor.com/project/dazinator/dotnet-glob/branch/master
Here is my appveyor.yml: https://github.com/dazinator/DotNet.Glob/blob/develop/appveyor.yml