Git克隆在Azure命令行任务中生成错误 [英] Git Clone generating an error in Azure Command Line Task

查看:98
本文介绍了Git克隆在Azure命令行任务中生成错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Azure DevOps CD管道中,我添加了一个命令行任务,用于克隆Git存储库.克隆成功完成,但是日志中有错误.

In my Azure DevOps CD pipeline, I have added a Command Line task which clones a Git repository. The clone is done successfully however there is an error in the log.

奇怪的行为是该克隆可以与Azure托管代理(例如 vs2017-win2016 windows-2019 )完美配合,但会产生错误(请参见下面的屏幕截图)如果我使用私人的本地代理人.

The strange behavior is that the clone works perfectly with an Azure hosted agent (like vs2017-win2016 or windows-2019) but generates the error (see below screenshot) if I use a private local agent.

命令行脚本:

git config --global user.email "my@email.com"
git config --global user.name "naregk"
git clone -c http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" https://naregk.visualstudio.com/txproject/_git/RepoD testrepoD

阶段结果:

出现的错误:

57.7114907Z ## [命令]"C:\ Nindows \ system32 \ cmd.exe"/D/E:ON/V:OFF/S/C "CALL" C:\ agent_work_temp \ aae38ede—905d—4d6d-9412-0 57.96819332 ## [错误]克隆到'testrepoD'... 06.96751142 ## [section]完成:命令行脚本

57.7114907Z ##[command]"C:\Nindows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "C:\agent_work_temp\aae38ede—905d—4d6d-9412-0 57.96819332 ##[error]Cloning into 'testrepoD'... 06.96751142 ##[section]Finishing: Command Line Script

推荐答案

某些git命令的输出可能是stderr(而不是stdout),而PowerShell认为这是一个错误.

Some git command output can be stderr (instead of stdout) and PowerShell think it's an error.

要解决此问题,您可以执行以下操作:

To solve it, you can do something like this:

$result = git clone -c ....... testrepoD 2>&1
Write-Host $result

这篇关于Git克隆在Azure命令行任务中生成错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆