How to git push from VSTS build

Problem:

When I run a git push from my VSTS build the push works but my build fails.

Solution:

Use the –q switch on your git push command.

Explanation:

By default the PowerShell and Command Line tasks in VSTS will fail if anything is written to standard error which makes perfect sense. 

image

Well it does until a tool writes status messages on standard error.

image

The line starting with “To https://” is the one causing all the issues. It is not an error but being written to standard error which causes the build to fail.

image

Luckily, we can use the –q switch to have it only write real errors to standard error and get the desired results.

image

Now when I run my build the build succeeds.

I also tested that if something bad really happened the build does fail as expected.

Add comment

Loading