Can I write custom task start/end records to VSTS build/release log

橙三吉。 提交于 2019-12-24 08:20:08

问题


I would like to be able to add items to the logs displayed during VSTS builds and releases:

I've looked at this page and written the following test powershell script

$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"

I was hoping to see additional entries in the log but I see no difference at all, not even the write-host statements appearing.

So I have 2 questions

  1. What should I see from my sample script above?
  2. Is it possible to get additional entries in that log shown in the initial screenshot without actually adding additional tasks?

回答1:


The syntax you're using is designed to show in the timeline which doesn't appear to be used in the new build layout yet (see here to disable preview of new build output). If you use the old build output, select the step for the powershell script you're executing and then select time line, you will then see your step (which in my case is ssloan) being logged by the logger. . See here for a better run down of the various build steps than I could give.

For just outputting the the logs you can use a variety of writers provided in PowerShell utilities Write-Host should be sufficient so long as you always have a host to write to. These will then appear in your logs



来源:https://stackoverflow.com/questions/51611259/can-i-write-custom-task-start-end-records-to-vsts-build-release-log

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!