我希望能够将项目添加到 VSTS 构建和发布期间显示的日志中:
我看过this page并编写了以下测试powershell脚本
$guid = $env:taskGuid
write-host "##vso[task.logdetail id=$guid;name=project1;type=build;order=1]create new timeline record"
# write-host "##vso[task.logdetail id=new guid;parentid=exist timeline record guid;name=project1;type=build;order=1]create new nested timeline record"
write-host "##vso[task.logdetail id=$guid;progress=50;state=InProgress;]update timeline record"
write-host "##vso[task.logdetail id=$guid;state=Completed;result=Succeeded]complete timeline record"
我希望在日志中看到其他条目,但我发现没有任何区别,甚至没有出现 write-host
语句。
所以我有两个问题
- 从上面的示例脚本中我应该看到什么?
- 是否可以得到 该日志中的其他条目如初始屏幕截图所示 没有实际添加额外的任务?
最佳答案
您正在使用的语法旨在显示在时间线中,该语法似乎尚未在新的构建布局中使用(请参阅 here 以禁用新构建输出的预览)。如果您使用旧的构建输出,请选择您正在执行的 powershell 脚本的步骤,然后选择时间线,您将看到记录器正在记录您的步骤(在我的例子中是 ssloan)。 。请参阅here为了比我能提供的更好地总结各种构建步骤。
如果只是输出日志,您可以使用PowerShell utilities中提供的各种编写器。只要您始终有一个可写入的主机,Write-Host 就足够了。这些将出现在您的日志中
关于azure-devops - 我可以将自定义任务开始/结束记录写入 VSTS 构建/发布日志吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51611259/