我可以将自定义任务开始/结束记录写入VSTS构建/发布日志

时间:2018-07-31 10:30:39

标签: azure-devops azure-pipelines azure-pipelines-release-pipeline azure-pipelines-build-task

我希望能够将项目添加到VSTS构建和发布期间显示的日志中: Log entries

我看过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语句。

enter image description here

所以我有2个问题

  1. 我应该从上面的示例脚本中看到什么?
  2. 是否有可能 初始屏幕快照中显示的该日志中的其他条目 无需实际添加其他任务?

1 个答案:

答案 0 :(得分:2)

您正在使用的语法旨在显示在时间轴上,而该时间轴似乎尚未在新的构建布局中使用(请参见here以禁用新的构建输出的预览)。如果使用旧的构建输出,请为您正在执行的Powershell脚本选择步骤,然后选择时间线,然后您将看到记录器正在记录您的步骤(在我的情况下为ssloan)。 vstsimage。请参阅here,以更好地掌握各种构建步骤,以尽我所能。

对于仅输出日志,您可以使用PowerShell utilities中提供的各种写入器,只要您始终有要写入的主机,“写入主机”就足够了。这些将出现在您的日志中