-
Notifications
You must be signed in to change notification settings - Fork 653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use gitversion as part of AppVeyor build #1477
Comments
I managed to use a workaround by checking out into a branch name
And naming my alpha tag |
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 |
Thanks @dazinator, I can see from Would you know in which scenario I would get the error |
@Kimserey afraid not but if I had to guess it sounds related to how the build server is checking out the repo - i.e in your case its in detached head mode. Perhaps its worth you asking the AppVeyor folks why your build would be different from my AppVeyor build in this regard.. |
Hi @dazinator , I had a look and it seems like the problem arise in the following circumstances:
Is it intended to behave this way or have I got the scenario wrong? Thanks! PS: I appreciate that you left the comment open even though it's been 2 months! Thanks a lot for your patience. On another note, I also can't get it to work on VSO (or also known as Azure Devops 😄). The commit gets checkout as a detached branch, here's in the default command to checkout repository:
Commit Which then result in the It seems to be related to the fact that it is in a detached branch and that the current checkout commit is on two different branches. This is the few last lines of the warning:
|
@JakeGinnivan @asbjornu @gep13 any ideas? |
@dazinator I wasn't aware of this, and I can't say that I have seen this happen on any of the repositories that I run in AppVeyor, where GitVersion is being used. |
Hi guys, thanks a lot for the follow up. I guess my question now changes slightly toward how to deal with repository like my test repository Is there a way to make GitVersion able to recognize the version even though the CI Server checks out on detached branch (talking about VSO here). VSO is executing the following commands, which if reproduced locally would yield the error:
@asbjornu , thanks a lot for the pointers but I couldn't understand how it relates and how I can use it? |
@Kimserey, there's nothing in those pull requests you can use yet, I was mostly referencing them to know which issues we might solve by finalizing them. 😃 To indicate which Git reference (branch or tag) a given commit is being built for, you provide GitVersion with the environment variable |
I just had the same experience with a PR build on Travis, so this doesn't seem to be exclusive to AppVeyor. #1314, #1501 and #1523 all seem to be about the same issue, indicating that this is something we ought to fix in GitVersion. Even setting the environment variable |
… is, we'll save it in an env. variable and pass it to the InvokeNextBuild script. See GitTools/GitVersion#1477 for more details.
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 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 #1477 (comment). The same problem did not happen with GitVersion 3.x. |
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. |
@dennisdoomen, are you sure this wouldn't happen with GitVersion 3.x, or have build servers just gotten a lot more aggressive wrt. reducing the amount of data they pull from a repository as of late? |
I don't think so, because the branch that still uses GitVersion 3 had no issues. |
Hm. I wonder what might be causing this that has changed since v3, then. Ideas? |
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. |
Also, #1523 seems to indicate that the problem existed in GitVersion 3.6.5 as well. |
I'm having issues all over the place with Gitlab CI, mainly the same issues. It complains about detached heads, and other issues like "Could not find a 'develop' or 'master' branch, neither locally nor remotely", while both exist. |
@m-jepson, are you sure - git fetch --unshallow || true # Travis might do a shallow clone, but GitVersion needs the full history including branches and tags
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
- git fetch origin
- git branch master origin/master || true # GitVersion seems to require a local "master" branch these days. That's a bug, but oh well.
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then git checkout -b "$TRAVIS_PULL_REQUEST_BRANCH-pr"; fi # Create an explicit branch on pull requests as I'm unable to pass Git_Branch into the Docker container for some |
Hi @asbjornu , I'll try your exact solution, rather than simplifying it. That's probably where I went wrong. I'll let you know how it works out. |
Well, this seems to work. Thanks for the help! |
I believe the change here is mostly in build servers, not in GitVersion. There's a bug in GitVersion around not treating What we can do is improve documentation around this, so it's clearer what to do when GitVersion fails in a build server. |
It seems to work, until I have it determine the version for the build of a specific tag: The final message is:
This is the script I use now:
And for the sake of completeness, this is the content of GitVersion.yml:
|
Is the |
I tried adding it, it is now set to the branch name, using |
New discovery, if I reset the master branch to the commit, using |
My Full script is now:
If we're building for a tag, |
If |
@m-jepson Did you manage to get this working? I'm experiencing the same issue. |
I had similar problems with the GitLab CI. I solved it by using the Dynamic Repository feature of GitVersion: > docker run --rm -v"$(pwd):/repo" gittools/gitversion:5.1.3-linux-ubuntu-18.04-netcoreapp3.1
/repo
/url ${CI_REPOSITORY_URL}
/b ${CI_COMMIT_REF_NAME}
/c ${CI_COMMIT_SHA} This works just fine for me. |
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. |
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:
But when Gitversion runs I see the following error:
I tried then using dynamic repository but it wouldn't checkout the branch on the right commit, for example:
It would checkout
test-branch
on the same level asmaster
branchf77f974
and not68264bd
.The text was updated successfully, but these errors were encountered: