Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stuck at fetch due to authentication issue

Tags:

git

jenkins

tfs

I have a Jenkins (2.0 Beta-2) server running on Windows 2012 R2 x64, with a new build configured to get source files from TFS GIT (2013). I have already installed the Git for Windows version provided by Microsoft - the one that claims to solve the authentication issue between GIT CLI and TFS GIT.

My .gitconfig looks like this:

[credential]
    helper = manager
    interactive = never
    validate = false
    integrated = true

Jenkins is running under a service account, with no interactive session. This service account is member of the local admin group on the build server, and is properly configured as a contributor on TFS. The issue here is that when the Jenkins build starts, it hangs during the following command:

git.exe -c core.askpass=true fetch --tags --progress http://my.tfs.server:8080/tfs/collection/_git/MyProject +refs/heads/*:refs/remotes/origin/*

To me, it seems clear that it is stuck, asking for credentials, even though I have set it to use the git-credential-manager. I have also tried to store the service account credentials, using the "store" command from the GCM, but it fails with an weird error (the syntax to use it is quite confusing, so it is possible that I'm doing something wrong while trying it).

like image 931
Fabricio Avatar asked Apr 07 '16 14:04

Fabricio


2 Answers

For us, unsetting the "credential.helper" git config variable entirely was the answer. Our jobs were hanging at the exact same spot after upgrading from Git 2.5.0 to 2.8.4, and our Jenkins service is running as Local System, so doing the following unset the variable:

git config --global --unset credential.helper
git config --system --unset credential.helper

No reboot or uninstall/reinstall was necessary. After that, builds from Git succeeded.

The Jenkins Git Client plugin appears to rely on the GIT_ASKPASS variable being set, which according to credential helper documentation is used when there are no credential helpers defined.

like image 189
Nick Jones Avatar answered Sep 20 '22 11:09

Nick Jones


After digging for a while I've found that I was not using the correct version of Git for Windows. It is known that the "standard" Git for Windows doesn't work very well with TFS GIT, mainly due to the lack of Kerberos support. I thought I was using the right version, but I wasn't.

As part of the build environment setup, I installed Visual Studio 2015. Along with it, it installs an incompatible version of Git for Windows, the one that doesn't work with TFS GIT (I really don't know why!). Even after installing the Git Credential Manager for Windows, the installed GIT version remains as the incompatible one.

Long story short: I had to manually uninstall both GIT and GCM, and install just GCM - which will then install the correct version of the GIT client during its installation.

After that, just reboot your server and things should "magically" work.

like image 41
Fabricio Avatar answered Sep 18 '22 11:09

Fabricio