0

I have a git authentication problem on Azure DevOps build agent for some unknown reason authentication only works with the MacPorts version of git:

>/usr/bin/git clone --config "http.sslVerify=false" "https://…:…@…/DefaultCollection/…/_git/…" 
Cloning into '…'...
fatal: Authentication failed for 'https://…:…@…/DefaultCollection/…/_git/…/'

>/usr/local/bin/git clone --config "http.sslVerify=false" "https://…:…@…/DefaultCollection/…/_git/…"
Klone nach '…' ...
fatal: Authentifizierung fehlgeschlagen für 'https://…/DefaultCollection/…/_git/…/'

>/opt/local/bin/git clone --config "http.sslVerify=false" "https://…:…@…/DefaultCollection/…/_git/…" 
Klone nach '…' ...
remote: Azure Repos
remote: Found 25399 objects to send. (22 ms)
Empfange Objekte: 100% (25399/25399), 21.80 MiB | 39.24 MiB/s, Fertig.
Löse Unterschiede auf: 100% (17128/17128), Fertig.

I have tried by best to make the build agent use the MacPorts version:

PATH GIT

But still the checkout fails:

##[section]Starting: Checkout
==============================================================================
Task         : Get sources
Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version      : 1.0.0
Author       : Microsoft
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
==============================================================================
Syncing repository: repository (ExternalGit)
##[command]git version
git version 2.26.2
##[command]git init "/Work/TFS/1/s"
Leeres Git-Repository in /Users/Shared/Work/TFS/1/s/.git/ initialisiert
##[command]git remote add origin https://…/DefaultCollection/…/_git/…
##[command]git config gc.auto 0
##[command]git config --get-all http.https://…/DefaultCollection/…/_git/….extraheader
##[command]git config --get-all http.proxy
##[command]git remote set-url origin https://***:***@…/DefaultCollection/…/_git/…
##[command]git remote set-url --push origin https://***:***@…/DefaultCollection/…/_git/…
##[command]git -c http.sslVerify=false fetch --force --tags --prune --progress --no-recurse-submodules origin
fatal: Authentifizierung fehlgeschlagen für 'https://…/DefaultCollection/…/_git/…/'
##[warning]Git fetch failed with exit code 128, back off 9.834 seconds before retry.
##[command]git -c http.sslVerify=false fetch --force --tags --prune --progress --no-recurse-submodules origin
fatal: Authentifizierung fehlgeschlagen für 'https://…/DefaultCollection/…/_git/…/'
##[warning]Git fetch failed with exit code 128, back off 8.115 seconds before retry.
##[command]git -c http.sslVerify=false fetch --force --tags --prune --progress --no-recurse-submodules origin
fatal: Authentifizierung fehlgeschlagen für 'https://…/DefaultCollection/…/_git/…/'
##[error]Git fetch failed with exit code: 128
##[section]Finishing: Checkout

So how can I make sure that the correct git executable is used? I tried to search for the script managing the checkout but to no avail.

Update 1: I have deinstall the Brew version of Git but this will only result in the the macOS Version to be used. And I can't deinstall that one.

Update 2: I placed a symbolic link ln -s /opt/local/bin/git /usr/local/bin/git. That actually works but it's not the best of workarounds and I would like for a more clean solution.

Martin
  • 11,577
  • 16
  • 80
  • 110
  • From the log, it looks like you're connecting to a Azure DevOps Server, not the hosted service. – jessehouwing May 20 '20 at 07:27
  • @jessehouwing Yes. Do note that the checkout works when `/opt/local/bin/git` is used. So it's not a connections error as such. More likely a problem with the Apple or Homebrew provided version of git. The MacPorts git is usually compiled from source so it might have a better integration and because of that it works. – Martin May 20 '20 at 13:18
  • @Martin, It seems we could not change the built-in task to use MacPorts git, how about my workaround? If it helps you? – Leo Liu May 21 '20 at 09:29

1 Answers1

0

How can i specify which git executable an Azure DevOps build agent uses

I am afraid we could not specify which git executable an Azure DevOps build agent uses. That because the checkout task is a built-in task, we could not customize it to use the other version git.

First, we could try to narrow the scope of this issue, for example, check this issue with hosted agent, if this issue still exists, then this issue should has nothing to do with the agent, please check whether our permissions are restricted:

VSTS Git Fetch Failed with exit code: 128

If the hosted agent works fine, try to update our private agent.

Besides, as a workaround, we could disable the checkout and manually clone the source code with git in specify version:

enter image description here

Then, add command line or powershell scripts to clone the source code, like:

cd \opt\local\bin

git clone https://<PAT>@dev.azure.com/<OrganizationName>/MyTestProject/_git/TestSample

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135