代码之家  ›  专栏  ›  技术社区  ›  ssloan

能否将自定义任务开始/结束记录写入VSTS生成/发布日志

  •  1
  • ssloan  · 技术社区  · 6 年前

    我希望能够将项添加到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

    所以我有两个问题

    1. 我应该从上面的示例脚本中看到什么?
    2. 有可能得到 初始屏幕截图中显示的日志中的其他条目 没有实际添加额外任务?
    1 回复  |  直到 6 年前
        1
  •  3
  •   Pete Philters    6 年前

    您正在使用的语法设计为在时间轴中显示,而该时间轴似乎尚未在新的生成布局中使用(请参见 here 禁用新生成输出的预览)。如果使用旧的生成输出,请为正在执行的powershell脚本选择步骤,然后选择时间线,您将看到日志记录器正在记录您的步骤(在我的示例中是ssloan)。 vstsimage . 见 here 为了更好地运行各种构建步骤。

    为了只输出日志,您可以使用 PowerShell utilities 只要您始终有一个要写入的主机,写主机就应该足够了。这些将出现在您的日志中