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
Implement
jetbrains.buildServer.serverSide.statistics.ValueType
, extendBuildFinishAwareValueTypeBase
orCompositeVTB
for convenienceRegister it using
jetbrains.buildServer.serverSide.statistics.ValueProviderRegistry.registerValueProvider
Custom build metrics details
Implement
jetbrains.buildServer.serverSide.statistics.build.BuildFinishAware
in yourValueType
to be notified of build finished event.Calculate your metric.
Employ
jetbrains.buildServer.serverSide.statistics.build.BuildDataStorage.publishValue
to publish your value.Employ
jetbrains.buildServer.serverSide.statistics.build.BuildDataStorage.getDataSet
to retrieve selected data.