问题
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
- What should I see from my sample script above?
- 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