tee*_*gee 5 python azure-devops azure-pipelines
我在构建管道中使用 python 对拉取请求运行一些检查。当检查失败时,我用来sys.exit('reason')退出脚本。这可行,但输出没有帮助。PR 页面中显示的内容如下:
进程“C:\hostedtoolcache\windows\Python\3.7.9\x64\python.exe”失败,退出代码为 1
我想知道如何将原因传递到此页面,以便开发人员不必深入研究管道日志来查看实际出了什么问题。在 powershell 中我可以使用以下命令:
Write-Host "##vso[task.logissue type=error;]Reason"
Write-Host "##vso[task.complete result=Failed;]Text"
Run Code Online (Sandbox Code Playgroud)
您也可以在 python 中使用相同的日志记录命令print():
steps:
- task: PythonScript@0
inputs:
scriptSource: inline
script: |
print("##vso[task.logissue type=error;]Reason")
print("##vso[task.complete result=Failed;]Text")
Run Code Online (Sandbox Code Playgroud)
在 PR 中你会看到:
| 归档时间: |
|
| 查看次数: |
2802 次 |
| 最近记录: |