TeamCity
 
You are viewing the documentation for an earlier version of TeamCity.

Custom Chart

Last modified: 20 April 2023

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.

Project page has charts added by default, see Customizing Statistics Charts.

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"> <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"> <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.

<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.

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.

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:

Note, that custom value keys should be unique and should not interfere with value keys predefined by TeamCity.

See also:

Concepts: Code Coverage | Code Inspection | Code Duplicates User's Guide: Statistic Charts Extending TeamCity: Build Script Interaction with TeamCity