简体   繁体   English

如何指定 Azure DevOps 构建代理使用的 git 可执行文件

[英]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.

相关问题 如何在Azure DevOps中创建使用外部git存储库和个人身份验证令牌的管道 - How can I create a pipeline in Azure DevOps that uses an external git repo and a personal authentication token 如何使用NAnt与Azure DevOps和Git进行构建? - How to use NAnt to build with Azure DevOps and Git? 如何将 SSRS 报告存储在 Git 中以用于 Azure DevOps? - How can I store SSRS reports in Git for use with Azure DevOps? 如何从 Azure Devops 中的特定分支构建? - How can I build from specific branch in Azure Devops? 在 Azure Devops 自托管代理服务器上的管道脚本中使用时,应如何配置 git 用户名和 email? - How should git username and email be configured when used in a pipeline script on an Azure Devops self hosted agent server? 我可以在Azure DevOps上更改Git全局配置吗 - Can I change Git global config on Azure DevOps 如何将克隆的 git 存储库 zip 文件添加到 Azure devops? - How can i add a cloned git repository zip file to Azure devops? 如何在同一存储库中的自述文件 markdown 文件中显示(链接到/超链接)Azure DevOps Git 存储库中的图像? - How can I display (link to/hyperlink) images that are in an Azure DevOps Git repo in a README markdown file in the same repo? 如何在 Azure DevOps 中的 PR 完成时添加 Git Hook commit-msg? - How can I add Git Hook commit-msg on PR Completion in Azure DevOps? 在使用 php curl 将文件上传到 Azure DevOps Git 之前如何获取 oldObjectId? - How can I get oldObjectId before uploading a file to Azure DevOps Git using php curl?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM