Search code examples
msbuildteamcitycakebuild

Cake - Is it possible to output my steps separately to TeamCity's statistics?


I am using Cake to build a solution on a TeamCity build server.

Currently, my build statistics are not at the point where I'd like them to be - for example, I can obtain total runtime for my tests in the Tests tab in TeamCity, and I can see the individual running time for these tests there, as well as the total run time of the build.

However, if I'd like to see how much time a particular step has been taking over time, I'd have to do it manually.

For example, given the below sample from an execution

[17:09:22]  [Step 1/1] Clean                                00:00:00.0301134    

[17:09:22]  [Step 1/1] Update-Version                       00:00:00.0826397    

[17:09:22]  [Step 1/1] Restore-Node-Packages                00:00:32.2691674    

[17:09:22]  [Step 1/1] Restore-NuGet-Packages               00:00:09.2550592    

[17:09:22]  [Step 1/1] Build-UI                             00:00:07.4544697    

[17:09:22]  [Step 1/1] Build                                00:04:12.2181356  

For a quick fix, I manually parsed this using Excel. I could wrangle up a script to parse this output, but I'd really rather not!

1) Is there a way for cake to output each step as a different build step so that TeamCity's graphs and statistics can naturally organize things?

2) If not, can I output the cake task results to some form of file? A CSV or XML would be fine, because I could at least go download them, or include them in the artifacts section, or something.

Thanks JM


Solution

  • Yes this is possible, the easiest way is probably using the Cake.BuildSystems.Module which can be fetched from nuget.org

    With TeamCity it will provide :

    • Build Logs are separated (and nested) for each executed task
    • Current/ongoing build status is updated to currently running task
    • Error logging aliases are highlighted in build log output

    Installation

    Using the latest bootstrapper

    If you're using the latest bootstrapper example (always available in this repo), you can simply add a tools/Modules/packages.config file with the following contents:

    <?xml version="1.0" encoding="utf-8"?>
    <packages>
         <package id="Cake.BuildSystems.Module" version="0.1.2" />
    </packages>