Custom Chart
In addition to statistic charts generated automatically by TeamCity, it is possible to configure your own statistical charts based on the set of build metrics provided by TeamCity or values reported from build script. In the latter case you will need to configure your build script to report custom statistical data to TeamCity.
Displaying a custom chart in TeamCity web UI
To make TeamCity display a custom chart in web UI, you need to update dedicated configuration file:
For Project-level chart:
<
>/config/<Project Name>/plugin-settings.xml
For Build Configuration-level chart:
<
TeamCity data dir
>/config/main-config.xml
You can edit these files while the server is running, they will be automatically reloaded.
A statistics chart is added using graph
tag. See the examples below:
Custom project-level charts in plugin-settings.xml
<settings> <custom-graphs> <!-- This tag is required only in plugin-settings.xml --> <graph title="Duration comparison" auxiliary-id="Duration comparison" hideFilters="showFailed" seriestitle="some key" auxiliary-id="some key" format="duration"> <valueType key="BuildDuration" title="duration2" auxiliary-id="duration2" buildTypeId="bt7"/> <valueType key="BuildDuration" title="duration1" auxiliary-id="duration1" buildTypeId="bt3"/> <valueType key="customKey" title="Custom data" auxiliary-id="Custom data" /> <!-- Will use data from build configuration bt3 --> </graph> </custom-graphs> </settings>
Custom build configuration-level charts in main-config.xml
<server ...> <!-- Some other stuff --> <graph title="Passed Test Count" auxiliary-id="Passed Test Count" seriestitle="Configuration" auxiliary-id="Configuration"> <valueType key="PassedTestCount" title="This configuration" auxiliary-id="This configuration" /> <valueType key="PassedTestCount" title="Passed Test Count" auxiliary-id="Passed Test Count" buildTypeId="bt32"/> <!-- This is explicit reference to build configuration --> </graph> <graph title="Tests against Coverage" auxiliary-id="Tests against Coverage"> <valueType key="PassedTestCount" title="Tests" auxiliary-id="Tests" /> <valueType key="CodeCoverageL" title="Line coverage" auxiliary-id="Line coverage" /> </graph> <graph title="Custom data" auxiliary-id="Custom data" seriestitle="Metric name" auxiliary-id="Metric name" format="size"> <valueType key="key1" title="Metric 1" auxiliary-id="Metric 1" /> <valueType key="key2" title="Metric 1" auxiliary-id="Metric 1" /> <valueType key="BuildDuration" title="Duration" auxiliary-id="Duration" /> </graph> </server>
Note, that when adding custom charts on the project level intermediate custom-graphs
tag is required.
Tags reference
<graph>: describes a single chart. It should contain one or more valueType
subtags, which describe series of data shown in the chart.
Attribute | Description |
---|---|
title | Title above the chart. |
seriesTitle | Title above list of series used on the chart (in singular form). Default is "Serie". |
defaultFilters | List of comma-separated options, which should be checked by default. Can include the following:
|
hideFilters | List of comma-separated filter names that should not be shown next to the chart:
|
format | Format of the y-axis values. Supported formats are:
|
<valueType>: describes a series of data shown on the chart. Each series is drawn with a separate color and you may choose one or another series using a filter.
Attribute | Description |
---|---|
key | A name of the valueType (or series). It can be predefined by TeamCity, like |
title | Series name, shown in the series selector. Defaults to <key>. |
buildTypeId | This field allows to explicitly specify build configuration to use data from for given valueType. This field is mandatory for the first valueType used in a chart, if the chart is added at project level. In other cases it is optional. However, note that TeamCity chooses build configuration to take data from according to following rules:
|
Build Metrics Provided by TeamCity
The following lists the pre-defined value providers that can be used to configure a custom chart. Using these values doesn't require build script modification.
Value | Description | Unit |
---|---|---|
ArtifactsSize | Sum of all Build Artifact file sizes in artifact directory. | Bytes |
BuildArtifactsPublishingTime | Duration of the artifact publishing step in the build | Milliseconds |
BuildCheckoutTime | Duration of the source checkout step | Milliseconds |
BuildDuration | Full build duration | Milliseconds |
CodeCoverageB | Block-level code coverage | % |
CodeCoverageC | Class-level code coverage | % |
CodeCoverageL | Line-level code coverage | % |
CodeCoverageM | Method-level code coverage | % |
CodeCoverageAbsLCovered | Number of covered lines | int |
CodeCoverageAbsMCovered | Number of covered methods | int |
CodeCoverageAbsCCovered | Number of covered classes | int |
CodeCoverageAbsLTotal | Total number of lines | int |
CodeCoverageAbsMTotal | Total number of methods | int |
CodeCoverageAbsCTotal | Total number of classes | int |
DuplicatorStats | Number of found code duplicates | int |
FailedTestCount | Number of failed tests in the build | int |
IgnoredTestCount | Number of ignored tests in the build | int |
InspectionStatsE | Number of inspection errors in the build | int |
InspectionStatsW | Number of inspection warnings in the build | int |
PassedTestCount | Number of successfully passed tests in the build | int |
SuccessRate | Indicator whether the build was successful | 0 - failed, 1 - successful |
TimeSpentInQueue | How much time build was in queue | Milliseconds |
Custom Build Metrics
If pre-defined build metrics do not cover your needs, you can report custom metrics to TeamCity from your build script and use them to create a custom chart. There are two ways to report custom metrics to TeamCity:
using Build Script Interaction with TeamCity from your build,
or using Build Script Interaction with TeamCity file.
Note, that custom value keys should be unique and should not interfere with value keys predefined by TeamCity.