Git Clone generating an error in Azure Command Line Task

筅森魡賤 提交于 2020-01-30 08:51:04

问题


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.

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.

Command Line Script:

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

The stage outcome:

The error which appears:

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


回答1:


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


来源:https://stackoverflow.com/questions/57786104/git-clone-generating-an-error-in-azure-command-line-task

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!