[英]How can i specify which git executable an Azure DevOps build agent uses
I have a git authentication problem on Azure DevOps build agent for some unknown reason authentication only works with the MacPorts version of git:我在 Azure DevOps 构建代理上有一个 git 身份验证问题,原因不明,身份验证仅适用于 git 的 MacPorts 版本:
>/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:我已经尽力让构建代理使用 MacPorts 版本:
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?那么如何确保使用了正确的 git 可执行文件? 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.更新 1:我已卸载 Git 的 Brew 版本,但这只会导致使用 macOS 版本。 And I can't deinstall that one.
我不能卸载那个。
Update 2: I placed a symbolic link ln -s /opt/local/bin/git /usr/local/bin/git
.更新 2:我放置了一个符号链接
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.这实际上可行,但这不是最好的解决方法,我想要一个更干净的解决方案。
How can i specify which git executable an Azure DevOps build agent uses
如何指定 Azure DevOps 构建代理使用的 git 可执行文件
I am afraid we could not specify which git executable an Azure DevOps build agent uses.恐怕我们无法指定 Azure DevOps 构建代理使用哪个 git 可执行文件。 That because the checkout task is a built-in task, we could not customize it to use the other version git.
那是因为结帐任务是一个内置任务,我们无法自定义它以使用其他版本 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:首先我们可以尝试缩小这个问题的scope,比如用托管代理检查这个问题,如果这个问题仍然存在,那么这个问题应该与代理无关,请检查我们的权限是否受到限制:
VSTS Git Fetch Failed with exit code: 128 VSTS Git 获取失败,退出代码: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:此外,作为一种解决方法,我们可以禁用签出并手动克隆指定版本的 git 源代码:
Then, add command line or powershell scripts to clone the source code, like:然后,添加命令行或 powershell 脚本来克隆源代码,例如:
cd \opt\local\bin
git clone https://<PAT>@dev.azure.com/<OrganizationName>/MyTestProject/_git/TestSample
Hope this helps.希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.