TeamCity 8.0 Help

Custom Statistics

TeamCity provides a number of ways to customize statistics. You can add your own custom metrics to integrate your tools/processes, insert any statistical chart/report into statistic page extension places and so on. This page describes programmatic approaches to statistics customization. For user-level customizations, please refer to Custom Chart.

Quick Start

  • An easy way to add custom statistics is to just insert a jsp fragment into WebPlace using a helper bean: <bean id="myLogoFragment" class="jetbrains.buildServer.web.openapi.SimpleWebExtension" init-method="register"> <property name="name" value="myLogoFragment"></property> <property name="place" value="BUILD_CONF_STATISTICS_FRAGMENT"></property> <property name="jspPath" value="/myLogoFragment.jsp"/> </bean>

  • To insert statistics chart into a jsp page: <%@taglib prefix="stats" tagdir="/WEB-INF/tags/chart"%> <stats:buildChart id="g1" valueType="BuildDuration"/>

  • To add a custom build metric, extend BuildValueTypeBase to just define your build metric calculation method, appearance, and key. After that you can reference this metric by its key in statistics chart/report tags.

More Details

BuildType Statistics tab extension point

//WebControllerManager webControllerManager webControllerManager.addPageExtension(WebPlace.BUILD_INFO_FRAGMENT, this);

Customizing chart appearance

  • width, height — chart image size

  • hideFilters — suppress filter controls

Adding custom metrics

  1. Implement jetbrains.buildServer.serverSide.statistics.ValueType, extend BuildFinishAwareValueTypeBase or CompositeVTB for convenience

  2. Register it using jetbrains.buildServer.serverSide.statistics.ValueProviderRegistry.registerValueProvider

Custom build metrics details

  1. Implement jetbrains.buildServer.serverSide.statistics.build.BuildFinishAware in your ValueType to be notified of build finished event.

  2. Calculate your metric.

  3. Employ jetbrains.buildServer.serverSide.statistics.build.BuildDataStorage.publishValue to publish your value.

  4. Employ jetbrains.buildServer.serverSide.statistics.build.BuildDataStorage.getDataSet to retrieve selected data.

Last modified: 20 April 2023