Today I decided to modify my build script output. I’m using psake and I want to take advantage of “Expand All” and “Collapse All” features in TeamCity’s Build Log.
After reading official documentation on http://bit.ly/1hjRXbT I realized implementation should be pretty easy, not trying to re-invent the wheel I’ve found the psake-contrib for TeamCity, http://github.com/psake/psake-contrib but the message block functions weren’t added.
Fork with added functions is available on http://github.com/dejx/psake-contrib.
This sample script should be enough to demonstrate the behaviour:
Task Default -depends Build
Task Build -depends Clean {
TeamCity-Block "Build" {
"Building a solution..."
}
}
Task Clean {
TeamCity-Block "Clean" {
"Cleaning some files..."
}
}
Running the Build target from powershell should produce following output
PS C:\Development\psake-contrib> psake
psake version 4.3.1
Copyright (c) 2010 James Kovacs
Executing Clean
##teamcity[blockOpened name='Clean']
Cleaning some files...
##teamcity[blockClosed name='Clean']
Executing Build
##teamcity[blockOpened name='Build']
Building a solution...
##teamcity[blockClosed name='Build']
Build Succeeded!
---------------------------------------
Build Time Report
---------------------------------------
Name Duration
---- --------
Clean 00:00:00.0120356
Build 00:00:00.0215277
Total: 00:00:00.0641303
Build log now looks like this