Assuming I am using a Powershell script task to perform some complex things, I want to let the azure pipeline know about the errors.
I know that using exit(0) is success and any non zero exit is a failure which will cause the azure pipeline task to fail (unless continue on error is enabled).
2nd approach is to use write-error which is same as above.
3rd approach is to use write-error to send the output to the stderr via powershell and then on the azure pipeline task set 'Fail on standard error' to true (check-mark). This approach can be used on its own and also along with both the above approachs.
Are there any other ways that I am missing?
If you use Write-Error
the task will fail even if Fail on standard error not checked.
Another option is to use alogging command task.logissue
:
##vso[task.logissue type=error;sourcepath=consoleapp/main.cs;linenumber=1;columnnumber=1;code=100;]this is an error
Results: