Skip to content
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

Unexpected change in behavior causing TeamCity issue #1874

Closed
santhonisz opened this issue Oct 29, 2019 · 13 comments · Fixed by #1879
Closed

Unexpected change in behavior causing TeamCity issue #1874

santhonisz opened this issue Oct 29, 2019 · 13 comments · Fixed by #1879
Assignees
Labels
Milestone

Comments

@santhonisz
Copy link
Contributor

Hi there,

We have started encountering failures in our TeamCity builds due to an apparent change in behavior of GitVersion since updating to the 5.1.1 release. It seems that the normalization process is now performing a git fetch by default, whereas in previous versions it did not. This is then causing an issue as we use SSH on our GitHub repositories. I am aware of the nofetch and new nonormalize switches, but I'm wondering if this change in behavior is intentional or is a regression issue?

GitVersion 5.0.1

[16:40:29]	INFO [10/28/19 16:40:29:01] Working directory: C:\buildAgent\work\44204f131946980e
[16:40:29]	INFO [10/28/19 16:40:29:02] IsDynamicGitRepository: False
[16:40:29]	INFO [10/28/19 16:40:29:04] Returning Project Root from DotGitDirectory: C:\buildAgent\work\44204f131946980e\.git - C:\buildAgent\work\44204f131946980e
[16:40:29]	INFO [10/28/19 16:40:29:04] Running on Windows.
[16:40:29]	INFO [10/28/19 16:40:29:04] Applicable build agent found: 'TeamCity'.
[16:40:29]	INFO [10/28/19 16:40:29:04] Branch from build environment: refs/pull/103/head
[16:40:29]	INFO [10/28/19 16:40:29:04] Begin: Normalizing git directory for branch 'refs/pull/103/head'
[16:40:29]	  INFO [10/28/19 16:40:29:08] One remote found (origin -> 'git@github.com:oneiress/iosplus-client.git').
[16:40:29]	  INFO [10/28/19 16:40:29:08] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories

GitVersion 5.1.1

[10:28:59]	INFO [10/29/19 10:28:59:30] Working directory: C:\buildAgent\work\44204f131946980e
[10:28:59]	INFO [10/29/19 10:28:59:31] IsDynamicGitRepository: False
[10:28:59]	INFO [10/29/19 10:28:59:33] Returning Project Root from DotGitDirectory: C:\buildAgent\work\44204f131946980e\.git\ - C:\buildAgent\work\44204f131946980e\
[10:28:59]	INFO [10/29/19 10:28:59:33] Running on Windows.
[10:28:59]	INFO [10/29/19 10:28:59:33] Applicable build agent found: 'TeamCity'.
[10:28:59]	INFO [10/29/19 10:28:59:33] Branch from build environment: refs/pull/104/head
[10:28:59]	INFO [10/29/19 10:28:59:33] Begin: Normalizing git directory for branch 'refs/pull/104/head'
[10:28:59]	  INFO [10/29/19 10:28:59:36] One remote found (origin -> 'git@github.com:oneiress/iosplus-client.git').
[10:28:59]	  INFO [10/29/19 10:28:59:36] Fetching from remote 'origin' using the following refspecs: +refs/heads/*:refs/remotes/origin/*.
[10:28:59]	  INFO [10/29/19 10:28:59:37] End: Normalizing git directory for branch 'refs/pull/104/head' (Took: 36.66ms)
[10:28:59]	  INFO [10/29/19 10:28:59:39] 
[10:28:59]	  ERROR [10/29/19 10:28:59:39] An unexpected error occurred:
[10:28:59]	  INFO [10/29/19 10:28:59:39] Attempting to show the current git graph (please include in issue): 
[10:28:59]	LibGit2Sharp.LibGit2SharpException: unsupported URL protocol
[10:28:59]	  INFO [10/29/19 10:28:59:39] Showing max of 100 commits
[10:28:59]	   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
[10:28:59]	   at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result)
[10:28:59]	   at LibGit2Sharp.Core.Proxy.git_remote_fetch(RemoteHandle remote, IEnumerable`1 refSpecs, GitFetchOptions fetchOptions, String logMessage)
[10:28:59]	   at LibGit2Sharp.Commands.Fetch(Repository repository, String remote, IEnumerable`1 refspecs, FetchOptions options, String logMessage)
[10:28:59]	   at GitVersion.Helpers.GitRepositoryHelper.Fetch(ILog log, AuthenticationInfo authentication, Remote remote, Repository repo)
[10:28:59]	   at GitVersion.Helpers.GitRepositoryHelper.NormalizeGitDirectory(ILog log, IEnvironment environment, String gitDirectory, AuthenticationInfo authentication, Boolean noFetch, String currentBranch, Boolean isDynamicRepository)
[10:28:59]	   at GitVersion.GitPreparer.Prepare(Boolean normalizeGitDirectory, String currentBranch, Boolean shouldCleanUpRemotes)
[10:28:59]	   at GitVersion.GitVersionCalculator.CalculateVersionVariables()
[10:28:59]	   at GitVersion.ExecCommand.Execute()
[10:28:59]	   at GitVersion.GitVersionExecutor.VerifyArgumentsAndRun(Arguments arguments)

Thanks,

Sam

@mderriey
Copy link

mderriey commented Oct 29, 2019

Hi there 👋

We're experiencing the same issue from an Azure Pipelines build.
Let us know if we can provide any more information to help.

A workaround is to use the /nonormalize flag when invoking GitVersion.

INFO [10/29/19 2:49:37:45] Applicable build agent found: 'AzurePipelines'.
INFO [10/29/19 2:49:37:46] Working directory: C:\agent\_work\7\sINFO [10/29/19 2:49:37:46] IsDynamicGitRepository: False
INFO [10/29/19 2:49:37:50] Returning Project Root from DotGitDirectory: C:\agent\_work\7\s\.git\ - C:\agent\_work\7\s\
INFO [10/29/19 2:49:37:50] Running on Windows.INFO [10/29/19 2:49:37:51] Applicable build agent found: 'AzurePipelines'.
INFO [10/29/19 2:49:37:51] Branch from build environment: refs/heads/set-office-property-in-azuread
INFO [10/29/19 2:49:37:51] Begin: Normalizing git directory for branch 'refs/heads/set-office-property-in-azuread'
INFO [10/29/19 2:49:37:60] One remote found (origin -> '<url-of-origin-remote>').
INFO [10/29/19 2:49:37:61] Fetching from remote 'origin' using the following refspecs: +refs/heads/*:refs/remotes/origin/*.
INFO [10/29/19 2:49:37:93] End: Normalizing git directory for branch 'refs/heads/set-office-property-in-azuread' (Took: 424.13ms)
ERROR [10/29/19 2:49:37:96] An unexpected error occurred:
LibGit2Sharp.LibGit2SharpException: request failed with status code: 401
   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
   at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result)
   at LibGit2Sharp.Core.Proxy.git_remote_fetch(RemoteHandle remote, IEnumerable`1 refSpecs, GitFetchOptions fetchOptions, String logMessage)
   at LibGit2Sharp.Commands.Fetch(Repository repository, String remote, IEnumerable`1 refspecs, FetchOptions options, String logMessage)
   at GitVersion.Helpers.GitRepositoryHelper.Fetch(ILog log, AuthenticationInfo authentication, Remote remote, Repository repo)
   at GitVersion.Helpers.GitRepositoryHelper.NormalizeGitDirectory(ILog log, IEnvironment environment, String gitDirectory, AuthenticationInfo authentication, Boolean noFetch, String currentBranch, Boolean isDynamicRepository)
   at GitVersion.GitPreparer.Prepare(Boolean normalizeGitDirectory, String currentBranch, Boolean shouldCleanUpRemotes)
   at GitVersion.GitVersionCalculator.CalculateVersionVariables()
   at GitVersion.ExecCommand.Execute()
   at GitVersion.GitVersionExecutor.VerifyArgumentsAndRun(Arguments arguments)

@davidkeaveny
Copy link
Contributor

I am experiencing this issue with GitVersion.Portable 5.1.1, running on TeamCity with the repository in BitBucket Cloud:, using SSH as the protocol.

INFO [10/29/19 16:02:23:93] Begin: Normalizing git directory for branch 'refs/heads/master'
INFO [10/29/19 16:02:24:19] One remote found (origin -> 'ssh://myproject@bitbucket.org/myproject/api.git').
INFO [10/29/19 16:02:24:19] Fetching from remote 'origin' using the following refspecs: +refs/heads/*:refs/remotes/origin/*.
INFO [10/29/19 16:02:24:21] End: Normalizing git directory for branch 'refs/heads/master' (Took: 280.89ms)
ERROR [10/29/19 16:02:24:24] An unexpected error occurred:
INFO [10/29/19 16:02:24:24] 
INFO [10/29/19 16:02:24:24] Attempting to show the current git graph (please include in issue): 
  LibGit2Sharp.LibGit2SharpException: unsupported URL protocol
INFO [10/29/19 16:02:24:24] Showing max of 100 commits
  at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
  at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result)
  at LibGit2Sharp.Core.Proxy.git_remote_fetch(RemoteHandle remote, IEnumerable`1 refSpecs, GitFetchOptions fetchOptions, String logMessage)
  at LibGit2Sharp.Commands.Fetch(Repository repository, String remote, IEnumerable`1 refspecs, FetchOptions options, String logMessage)
  at GitVersion.Helpers.GitRepositoryHelper.Fetch(ILog log, AuthenticationInfo authentication, Remote remote, Repository repo)
  at GitVersion.Helpers.GitRepositoryHelper.NormalizeGitDirectory(ILog log, IEnvironment environment, String gitDirectory, AuthenticationInfo authentication, Boolean noFetch, String currentBranch, Boolean isDynamicRepository)
  at GitVersion.GitPreparer.Prepare(Boolean normalizeGitDirectory, String currentBranch, Boolean shouldCleanUpRemotes)
  at GitVersion.GitVersionCalculator.CalculateVersionVariables()
  at GitVersion.ExecCommand.Execute()
  at GitVersion.GitVersionExecutor.VerifyArgumentsAndRun(Arguments arguments)
INFO [10/29/19 16:02:24:52] * 0bd20129 10 minutes ago  (HEAD -> master, origin/master)

@davidkeaveny
Copy link
Contributor

In my case, downgrading to 5.0.1 and clearing the auto-update setting in TeamCity avoids the issue.

@jakubsuchybio
Copy link
Contributor

jakubsuchybio commented Oct 29, 2019

#MeToo but /nonormalize from @mderriey helped

@Bishbulb
Copy link

#MeToo. All of our TC builds suddenly started failing yesterday. Going to try @davidkeaveny's suggestion and downgrade and disable the auto-update setting.

@bencameron
Copy link

I'm getting the same issue in Azure DevOps. We're using GitVersion.CommandLine within a Cake script and started seeing the same errors yesterday. We've updated a few critical build scripts to pin to the 5.0.1 version, but we're waiting to hear if this new behavior is permanent before applying a fix to all of our other scripts.

Does anyone know if this behavior is here to stay?

@arturcic arturcic added the bug label Oct 29, 2019
@arturcic arturcic self-assigned this Oct 29, 2019
@claudiuconstantin
Copy link

I also encountered this, the temporary solution was to downgrade to v5.0.1

@mderriey
Copy link

mderriey commented Nov 1, 2019

Hey @arturcic, I'm really not familiar with the code base, but if you have pointers, I should have some time next week to try and have a look at this.

@arturcic
Copy link
Member

arturcic commented Nov 2, 2019

@santhonisz , @mderriey can you check version 5.1.2-beta.1+4 if it fixed the error?

@mderriey
Copy link

mderriey commented Nov 4, 2019

We installed 5.1.2-beta.1+5 and it worked fine without the /nonormalize flag.

Thanks heaps! 👍

@arturcic
Copy link
Member

arturcic commented Nov 4, 2019

Closing as there's a confirmation it worked

@arturcic arturcic closed this as completed Nov 4, 2019
@rmajid2
Copy link

rmajid2 commented Nov 13, 2019

Usage of GitVersion as script in Azure Pipelines Hosted Windows 2019 with VS2019 (v20191028.1) throw exception (As v20191028.1 include V5.1.1.0 of GitVersion):
LibGit2Sharp.LibGit2SharpException: request failed with status code: 401

A workaround and a temporary solution was to downgrade to v5.0.1 by using the GitVersion task wich use v5.0.1 of GitVersion

@arturcic
Copy link
Member

arturcic commented Nov 13, 2019

@rmajid2 5.1.1 has several bugs. We fixed most of them in 5.1.2 so you could use 5.1.2 with the GitVersion Task extension. Hopefully the Azure Pipeline image will get updated soon

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.

9 participants