2

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 "[email protected]"
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:

enter image description here

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

enter image description here

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

3 Comments

This thread might give some more ideas how to deal with this situation.
@YanSklyarenko and @Shayki Abramczyk, thanks for the tips. My solution was to use PowerShell and not Command Line task and added $env:GIT_REDIRECT_STDERR = '2>&1' before the the git commands.
@naregkar you're welcome! only now I saw you specified command line in the question... and I answered with PowerShell script... sorry! your solution is also good :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.