Azure Powershell VSO agent task not failing for non-zero exit code

724 views Asked by At

When putting together a release definition in VSO, adding an Azure PowerShell task backed by a file Script1.ps only containing exit 1 does not fail the step when it runs - which I would expect it to do, given that the Continue on error box is not checked If I add the PowerShell task, writing exit 1 using the inline variant would indeed fail the step. This also comes with an 'advanced configuration option' where the Fail on Standard Error is checked by default.

What did I miss? How would I go about making the Azure Powershell fail in the same manner?

2

There are 2 answers

0
starian chen-MSFT On BEST ANSWER

Using this code instead:

[Environment]::Exit(1)
0
Roopesh Nair On

The task will fail if the script throws an exception or writes to stderr stream.