How can I create a custom build metric displaying percentage?

I am using a coverage tool not supported by team city. In order to report on insufficient code coverage I need to add a new build metric which preferably should be given in percents.

When publishing default build metrics using service messages, absolute values (e.g. CodeCoverageAbsLCovered and CodeCoverageAbsLTotal) should be used instead of percentage values (e.g. CodeCoverageL). The percentage values are then computed from the absolute values (ref http://confluence.jetbrains.com/display/TCD8/How+To...#HowTo...-ImportcoverageresultsinTeamCity). Can I do the same with my custom build metric? How?

1 comment
Comment actions Permalink

Ability to compute percentage from absolute values is available for default coverage metrics only (class, method, line and block). You can still publish percentage itself (eg "

##teamcity[buildStatisticValue key=
'coverage.branch'
 
value=
'89'
]
" where 89 stands for branch coverage percentage). Using the key ('coverage.branch' in my example) you can add custom charts with format='percent' attribute:

 <graph title=
"Branch coverage"
 
format=
"percent"
>
    <valueType key="
coverage.branch
"
 
title="coverage"/>

  </graph>


You can use this value as build metric (for build failure condition) as described here as well.

Please note than at the moment TeamCity doesn't support statistic values with floating point so you can't publish accurate values this way. It's possible to create a plugin to achieve same functionality as for default coverage metrics.

0

Please sign in to leave a comment.