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 the Custom Chart page.
To add a chart to the Statistics tab for a project or build configuration, use the ChartProviderRegistry
bean:
public MyExtension(ChartProviderRegistry registry, ProjectManager manager) {
registry.getChartProvider("project-graphs").registerChart(manager.findProjectByExternalId("externalId"), createGraphBean());
// "project-graphs" for Project Statistics Tab
// "buildtype-graphs" for Build Configuration Statistics Tab
}
public GraphBean createGraphBean() {
// creates GraphBean
}
To add custom content to the Statistics tab for a project or build configuration, use the following example here and the appropriate PlaceId
:
for Build Configuration Statistics tab, use
PlaceId.BUILD_CONF_STATISTICS_FRAGMENT
for Project Statistics tab, use
PlaceId.PROJECT_STATS_FRAGMENT
.
To add charts to your custom JSP pages, use the <buildGraph>
tag and a special controller accessible on "/buildGraph.html"
. It requires the jsp
attribute leading to your page:
new ModelAndView("/buildGraph.html?jsp=" +myDescriptor.getPluginResourcesPath("sampleChartPage.jsp"))'
To insert statistics chart into the sampleChartPage.jsp
:
<%@taglib prefix="stats" tagdir="/WEB-INF/tags/graph"%>
<stats:buildGraph id="g1" valueType="BuildDuration"/>
Attribute | Description | Usage |
---|---|---|
| modify the chart image size | Integer value |
| suppress filter controls | Comma separated filters names: |
| default filter state | Comma separated names: |
| chart style | Set to |
To add a custom build metric, in addition to the built-in methods, you can extend BuildValueTypeBase
to define your build metric calculation method, appearance, and key. After that you can reference this metric by its key in statistics chart/report tags.
See also:
Extending TeamCity: Build Script Interaction with TeamCity
Thanks for your feedback!