In TeamCity, it is possible to configure a build script to report statistical build data (build metrics) and then display the data on charts.
To display a custom chart you will need to configure your build script to report the data and configure TeamCity to show the corresponding charts.
Configuring Charts Presentation
TeamCity allows to display custom charts either on the Build Configuration Statistics page or on the Project Statistics Page, depending on the settings.
The settings for custom charts are stored in the XML files. In the chart configuration, you can use either pre-defined metrics provided by TeamCity, or the values reported from the build script.
Build-Configuration Level Charts
The chart is shown on the Statistics tab of the Build Configuration. The chart is displayed for those Build Configurations that has appropriate data reported by the builds.
The settings are configured in the <TeamCity data dir>/config/main-config.xml file by "graph" tags. You can edit the file while server is running, it will be automatically reloaded.
The chart is shown on the Statistics tab for the individual Project.
The settings are configured in the <TeamCity data dir>/config/<Project Name>/plugin-settings.xml file by "graph" tags. You can edit the file while server is running, it will be automatically reloaded.
Almost the same as for main-config.xml, but there is an intermediate custom-graphs tag:
This tag describes a single chart. It may contain one or more valueType subtags, which describe series of data shown on the chart.
||Title above the chart
|| Title above list of series used on the chart (in singular form). Defaults to "Serie"
||List of comma-separated options, which should be checked by default. May include the following options:
- showFailed — include results from failed builds by default
- averaged — by default, show averaged values on the chart
||List of comma-separated filter names, which should not be shown near the chart:
- all — hide all filters
- series — hide series filter (you won't be able to show only data from specific value type specified for the chart
- range — hide date range filter
- showFailed — hide checkbox which allows to include data for failed builds
- averaged — hide checkbox which allows to view averaged values
Defaults — empty (all filters are shown)
This tag 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. The attributes of the tag are:
||A name of the value type (or series). It may be predefined by TeamCity, like "BuildDuration" or "ArtifactsSize", or you can provide your own data (see below)
||Series name, shown in the series selector. Defaults to <key>.
||This field is mandatory for the first value type used in a chart on Project Statistics page, and can be omitted in other cases. It allows to specify build configuration, whose data will be shown for given value type. The build configuration for the data is chosen by the following rules:
- if buildTypeId is set for the value type, data will be taken from this setting (even if corresponding build configuration belongs to another project)
- if buildTypeId is not set for the current value type, but it is set for a value type above current one within the chart, the data from the build configuration referenced above will be taken. See example for plugin-settings.xml file above.
- if buildTypeId is not set for the current value type and is not set above, the chart will show data for the current build configuration, i.e. this chart will work only for Statistics tab of the build configuration. Such charts can be configured only in main-config.xml.
Data Sources (valueType keys)
Pre-defined Value Providers
||Sum of all artifact file sizes in artifact directory.
||Duration of the artifact publishing step in the build.
||Duration of the source checkout step.
||Build duration, excluding checkout or artifact publishing time.
||Block-level code coverage
||Class-level code coverage
||Line-level code coverage
||Method-level code coverage
||Number of found code duplicates
||Number of failed tests in the build
||Number of ignored tests in the build
||Number of inspection errors in the build
||Number of inspection warnings in the build
|| Number of successfully passed tests in the build
|| Indicator whether the build was successful
||0 - failed, 1 - successful
|| Number of failed tests in the build
|| How much time build was in queue
|The following predefined value providers are not supported for custom charts:
Reporting Custom Charts Data
|Custom value keys should not interfere with value keys for predefined value providers described above.|
There are two ways to publish values for custom metrics — using teamcity-info.xml file or using service messages from your build.