Reputation: 123
I'm using python in my build pipeline to run some checks on pull requests. When checks fail, I use sys.exit('reason')
to exit the script. This works but the output is not helpful. All that's shown in the PR page is this:
The process 'C:\hostedtoolcache\windows\Python\3.7.9\x64\python.exe' failed with exit code 1
I would like to know how to pass the reason to this page so the developers don't have to dig into the pipeline log to see what actually went wrong. In powershell I can use the following commands:
Write-Host "##vso[task.logissue type=error;]Reason"
Write-Host "##vso[task.complete result=Failed;]Text"
Upvotes: 7
Views: 3362
Reputation: 41745
You can use the same logging commands in python also, with print()
:
steps:
- task: PythonScript@0
inputs:
scriptSource: inline
script: |
print("##vso[task.logissue type=error;]Reason")
print("##vso[task.complete result=Failed;]Text")
In the PR you will see:
Upvotes: 9