Skip to content

[Bug] Azure DevOps: Empty git branch on PR triggered build agent when Gitversion Setup is run #3083

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

Closed
shaneocall opened this issue Apr 14, 2022 · 4 comments · Fixed by #3085
Labels
Milestone

Comments

@shaneocall
Copy link

Describe the bug
With GitVersion 5.10.0, ion Azure DevOps, when GitVersion is installed on a build agent which was triggered by an automated PR Build Validation. The git branch is returned as an empty string and Gitversion setup fails.

Expected Behavior

In Gitversion 5.9.0, for PR a numbered 1751, the below can be seen in the output:
image

Actual Behavior

In Gitversion 5.10.0, for PR a numbered 1758, the below can be seen in the output:
image

Possible Fix

Steps to Reproduce

  • Using AzureDev Ops repo
  • Add a Build Validation in the Repo settings:
    image
  • In the azure-pipelines.yml build file, install GitVersion and run gitversion Setup
    image
  • Create a PR in DevOps and Queue the build validation:
    image

Context

Unable to use pre-merge Build Validation in Azure Devops with GitVersion 5.10.0

Further information

Error further down the logs:

refs/remotes/pull/1758/merge (29cb882c4287dfc0c9ce867d43149a74154600cf) INFO [04/14/22 15:31:25:28] No local branch pointing at the commit '29cb882c4287dfc0c9ce867d43149a74154600cf'. Fake branch needs to be created. INFO [04/14/22 15:31:25:29] Fetching remote refs to see if there is a pull request ref INFO [04/14/22 15:31:25:33] End: Normalizing git directory for branch '' (Took: 182.17ms) ERROR [04/14/22 15:31:25:35] An unexpected error occurred: LibGit2Sharp.LibGit2SharpException: this remote has never connected at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 154 at LibGit2Sharp.Core.Proxy.git_remote_ls(Repository repository, RemoteHandle remote) in /_/LibGit2Sharp/Core/Proxy.cs:line 2324 at LibGit2Sharp.Network.ListReferencesInternal(String url, CredentialsHandler credentialsProvider) in /_/LibGit2Sharp/Network.cs:line 130 at LibGit2Sharp.Network.ListReferences(Remote remote) in /_/LibGit2Sharp/Network.cs:line 55 at GitVersion.GitRepository.GetPullRequestReference(AuthenticationInfo auth, Remote remote, String headTipSha) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\GitRepository.cs:line 151 at GitVersion.GitRepository.<>c__DisplayClass28_0.<CreateBranchForPullRequestBranch>b__0() in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\GitRepository.cs:line 79 at GitVersion.RepositoryExtensions.RunSafe(Action operation) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\RepositoryExtensions.cs:line 15 at GitVersion.GitRepository.CreateBranchForPullRequestBranch(AuthenticationInfo auth) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\GitRepository.cs:line 69 at GitVersion.GitPreparer.<>c__DisplayClass18_0.<EnsureHeadIsAttachedToBranch>b__3() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 237 at GitVersion.Helpers.RetryAction`1.<>c__DisplayClass1_0.<Execute>b__0() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Helpers\RetryAction.cs:line 16 at Polly.Policy`1.<>c__DisplayClass11_0.<Execute>b__0(Context _, CancellationToken _) at Polly.Retry.RetryEngine.Implementation[TResult](Func`3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates`1 shouldRetryResultPredicates, Action`4 onRetry, Int32 permittedRetryCount, IEnumerable`1 sleepDurationsEnumerable, Func`4 sleepDurationProvider) at Polly.Retry.RetryPolicy`1.Implementation(Func`3 action, Context context, CancellationToken cancellationToken) at Polly.Policy`1.Execute(Func`3 action, Context context, CancellationToken cancellationToken) at Polly.Policy`1.Execute(Func`1 action) at GitVersion.Helpers.RetryAction`2.Execute(Func`1 operation) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Helpers\RetryAction.cs:line 35 at GitVersion.Helpers.RetryAction`1.Execute(Action operation) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Helpers\RetryAction.cs:line 14 at GitVersion.GitPreparer.EnsureHeadIsAttachedToBranch(String currentBranchName, AuthenticationInfo authentication) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 237 at GitVersion.GitPreparer.NormalizeGitDirectory(Boolean noFetch, String currentBranchName, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 183 at GitVersion.GitPreparer.NormalizeGitDirectory(String targetBranch, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 134 at GitVersion.GitPreparer.PrepareInternal(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 69 at GitVersion.GitPreparer.Prepare() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 48

@shaneocall shaneocall added the bug label Apr 14, 2022
@arturcic
Copy link
Member

Thank you for the details

@arturcic
Copy link
Member

closed this in #3085

@arturcic arturcic added this to the 5.10.1 milestone Apr 14, 2022
@github-actions
Copy link

🎉 This issue has been resolved in version 5.10.1 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

@arturcic
Copy link
Member

@shaneocall please confirm it's working for you with version 5.10.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants