Custom Chart
In addition to statistic charts generated automatically by TeamCity on the Statistics tab, it is possible to configure your own statistical charts based on the set of statistic values provided by TeamCity or values reported from a build script. In the latter case you will need to configure your build script to report custom statistical data to TeamCity.
Note that since TeamCity 8.1, you can view statistics charts on the Build parameters page.
Displaying Custom Chart in TeamCity Web UI
To make TeamCity display a custom chart in the web UI, you need to update the dedicated configuration file:
For Project-level chart:
<
>/config/projects/<
ProjectID
>/pluginData/plugin-settings.xml
For Build Configuration-level chart:
<
>/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 the graph
tag. See the examples below:
Custom project-level charts in plugin-settings.xml
Custom build configuration-level charts in main-config.xml
Note that when adding custom charts on the project level, the 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 | The title above the chart. |
seriesTitle | The title above the list of series used on the chart (in the singular form). The default is "Serie". |
defaultFilters | The list of comma-separated options to be checked by default. Can include the following:
|
hideFilters | The list of comma-separated filter names that will not be shown next to the chart:
|
format | The 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 | The series name shown in the series selector. Defaults to <key>. |
buildTypeId | This field allows you to explicitly specify a build configuration to use the data from for the given valueType. This field is mandatory for the first valueType used in a chart if the chart is added at the project level. In other cases it is optional. However, note that TeamCity chooses the build configuration to take the data from according to the following rules:
|
color | The color of a series to be used in the chart. Standard web color formats can be used - "#RRGGBB", color names, etc. For more information see HTML Colors reference and HTML Color Names reference. If not specified, an automatic color will be assigned based on the series title. |
Chart Dimensions
You can set the custom chart width/height in pixels using the width
and height
properties within the XML properties
tag:
Chart Axis Settings
You can also customize the default axis settings for a chart via properties added withing the XML properties
tag:
Supported properties:
Name | Description |
---|---|
axis.y.type | Logarithmic for the logarithmic Y axis scale, linear for the standard scale. The default is linear. |
axis.y.includeZero | Whether the zero value is included on the Y axis (true) or not (false). The default is true. |
axis.y.min | An integer value to start the Y axis from. |
axis.y.max | An integer value to use as the maximum for the Y axis value . |
Default Statistics Values Provided by TeamCity
The table below lists the predefined value providers that can be used to configure a custom chart. The values reported for each build differ depending on your build configuration settings.
Key | Description | Unit |
---|---|---|
ArtifactsSize | The sum of all artifact file sizes in the artifact directory | Bytes |
VisibleArtifactsSize | Since TeamCity 8.1, the sum of all artifact file sizes excluding hidden artifacts (those placed under .teamcity directory) | Bytes |
BuildArtifactsPublishingTime | The duration of the artifact publishing step in the build | Milliseconds |
BuildCheckoutTime | The duration of the source checkout step | Milliseconds |
BuildDuration | The build duration (all build stages) | Milliseconds |
CodeCoverageB | Block-level code coverage | % |
CodeCoverageC | Class-level code coverage | % |
CodeCoverageL | Line-level code coverage | % |
CodeCoverageM | Method-level code coverage | % |
CodeCoverageAbsLCovered | The number of covered lines | int |
CodeCoverageAbsMCovered | The number of covered methods | int |
CodeCoverageAbsCCovered | The number of covered classes | int |
CodeCoverageAbsLTotal | The total number of lines | int |
CodeCoverageAbsMTotal | The total number of methods | int |
CodeCoverageAbsCTotal | The total number of classes | int |
DuplicatorStats | The number of code duplicates found | int |
TotalTestCount | The total number of tests in the build | int |
PassedTestCount | The number of successfully passed tests in the build | int |
FailedTestCount | The number of failed tests in the build | int |
IgnoredTestCount | The number of ignored tests in the build | int |
InspectionStatsE | The number of inspection errors in the build | int |
InspectionStatsW | The number of inspection warnings in the build | int |
SuccessRate | An indicator whether the build was successful | 0 - failed, 1 - successful |
TimeSpentInQueue | How long the build was queued | Milliseconds |
Since TeamCity 8.1, you can view the all statistic values reported by the build on the Build Results|Parameters|Reported statistic values tab. For each of the values, a statistics chart is available on clicking the View Trend icon .
Custom Build Metrics
If the predefined 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 service messages from your build,
or using the Build Script Interaction with TeamCity file.
Note that custom value keys should be unique and should not interfere with value keys predefined by TeamCity.