12

Is it possible to format powershell output so that it renders as a collapsible section in the TeamCity build log, Tree view?

So for example, my build step uses a powershell runner, and issues a

write-host " #################  deployment manifest ############################"
ls -r -i *.* | %{ $_.FullName }

which outputs this:

[15:28:13] #################  deployment manifest ############################
[15:28:13]\\10.10.10.49\d$\sites\account.foo.net\v32\Bin
[15:28:13]\\10.10.10.49\d$\sites\account.foo.net\v32\contact
[15:28:13]\\10.10.10.49\d$\sites\account.foo.net\v32\Content
[15:28:13]\\10.10.10.49\d$\sites\account.foo.net\v32\controls
[15:28:13]\\10.10.10.49\d$\sites\account.foo.net\v32\error

I'd like that chunk of the log to be collapsible in the Tree View.

Josh Buedel
  • 1,853
  • 16
  • 41
  • 1
    What are the criteria that make it collapsible? I know PowerShell, but I have no idea how TeamCity works in that regard (nor do I have a clue what it even *is*). – Joey Apr 27 '12 at 20:45
  • Have you thought of creating html/html5 document with the output? You can just start write-host to a document and write in your markup, afterwards voila.. – dc5553 Apr 27 '12 at 20:54
  • What version of TeamCity are you using? – Bronumski Apr 27 '12 at 21:13

1 Answers1

19

Yes we do this with our powershell scripts, you need to get your build script to update Teamcity with the build status. More specifically you need to report the build progress which will tell Teamcity when the start and the end of a block of work occurs. After the build has finished Teamcity will use this information to create nodes on the tree view of the log.

In powershell do the following:

write-host "##teamcity[progressStart '<message>']"

do work

write-host "##teamcity[progressFinish '<message>']"

Note You need to make sure that the message is the same in the start and finish message, blocks can be nested. You can also use the block message instead. I don't know exactly what the difference is but you appear to get the same results:

write-host "##teamcity[blockOpened name='<blockName>']"

do work

write-host "##teamcity[blockClosed name='<blockName>']"
Bronumski
  • 14,009
  • 6
  • 49
  • 77
  • 1
    Working with TC 8. Message from `progressStart` was only shown in the Overview page. Message from `blockOpened` indeed caused folding in the TreeView – Ilia Barahovsky Mar 10 '14 at 14:28