Can I format powershell output into collapsible Tree View in TeamCity logs?

此生再无相见时 提交于 2019-12-03 20:43:08

问题


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.


回答1:


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>']"


来源:https://stackoverflow.com/questions/10357525/can-i-format-powershell-output-into-collapsible-tree-view-in-teamcity-logs

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