Get Code Coverage % set as statistic
Hi
I'm trying to customise my Status message text to include Code Coverage, but I'm having trouble obtaining the numbers.
I'm using JaCoCo and importing the report with
##teamcity[jacocoReport dataPath='build/jacoco/test.exec' includes='com.example.*'
And I can see in jacoco.log that it is recording the results as
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value = '14133'] ##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value = '5267']
...
Is there some way I can read these statistic values during build or somehow intercept them so I can use them to customise my build status message? Or am I going in the wrong direction, and this is a dead end?
Thank you for any help.
João
Please sign in to leave a comment.
Hi João,
I'm afraid that, during the build, this value is still not calculated. They're set up at the very end of the build because it's possible to have multiple code coverage steps. As my colleague Yegor pointed out in this comment, there aren't really many options to accomplish this: https://teamcity-support.jetbrains.com/hc/en-us/community/posts/206211899-Having-Code-Coverage-Appear-in-Build-Status-Text
The other possibility is, if you are able to, to parse the code coverage reports via a script and then publish a text based on your parsing. It's not trivial but it might be easier than creating your own plugin for it.