0
votes

Within the new Build steps, is it possible to have a PowerShell script log some sort of timeline, similar to what the MSBuild task does? This is displayed under the timeline tab when you open a running or completed build in the web interface and select the specific task.

We have a large build that builds about 700 projects, with the MSBuild task you can somewhat see the progress of this, the timing is not correct because of the dependencies that are being build as part of the first project, but thats alright. We have a powershell script that loops over all solutions after the build step and performs other tasks. At this moment only the messages, warnings and errors are logged back to the web interface, but it would be nice if we could build output the list we loop through and see the progress of that list. Possibly with the green check-marks for projects that are done.

Is it possible to make something like that ?

let me know if i need to further clarify myself.

1

1 Answers

0
votes

I think i have found what i need here https://github.com/Microsoft/vsts-tasks/blob/986f8f5112017474962affe58c9ebaf394fb9354/docs/authoring/commands.md

Edit: Confirmed this is what i needed. First i loop over all items and create the initial "Initialized" entry, which will make sure the entry shows in the timeline but not as started. The guid seems to be required, i tried a unique string first, but for some reason that didnt work.

$projectKey = GetSomeProjectKey
$guid = [guid]::NewGuid()

Write-Host $solution.FullName
Write-Host "##vso[task.logdetail id=$($guid);name=$($projectKey);type=build;order=$i;state=Initialized;]"
$guidDictionary.Add("$projectKey", "$guid")

Then in the loop where you do the work, make sure you set the task to InProgress, set the Starttime to make sure you get a duration value

$startDate = "$(Get-Date -Format 'yyyy/MM/dd HH:mm:ss')"
$projectKey = GetSomeProjectKey

Write-Host  "##vso[task.logdetail id=$($guidDictionary[$projectKey]);progress=10;state=InProgress;starttime=$($startDate)]"

And when your done, close the task and set the proper state along with the finishtime

$endDate = "$(Get-Date -Format 'yyyy/MM/dd HH:mm:ss')"
Write-Host "##vso[task.logdetail id=$($guidDictionary[$projectKey]);progress=100;state=Completed;result=Succeeded;finishtime=$($endDate)]"

In the web interface you can now see how much time was spend on each step in your build step along with the result if you set it.