Build Failure Conditions with Custom Metrics

I am using the feture Fail Build on metric change to mark builds as failed when a custom Build Metric changes.

Two questions:

1.  One of the metrics that I am trending is a percentage value (percentage of static code violations).  I have added this statistic into the TeamCity configuration file <TeamCity Data Directory>/config/main-config.xml as suggested in the Build Failure Conditions documentation:

<build-metrics>

<statisticValue key="myMetric" description="build metric for number of files"/>

</build-metrics>


How can I have this build statistic value display as a floating point percentage?  (i.e. How do I change the metrics for build statistics?)  It is currently rounding the value to an integer.  I see other build statistics (i.e. Success Rate) presented as a percentage, so I can assume it can be done.



2. The metric change failure condition I have set is to "compared to the last successful build".  Can anyone provide more insight into specifics of what "last successful" means?  We are using git-flow and have multuple branches building for each TeamCity project.  Does this failure condition only compare against the last successful build on the same branch?  Or could a build on the master branch be compared to the last successful build on a feature branch (this is not desired.)?

Thanks,

Brian
5 comments
Comment actions Permalink

It looks like I found my own answer to #1:

It doesn't look like this is possible in the currently released versions of TeamCity. From this following discussion board:

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.


But I am still looking for some guidance on #2.  Thanks!
0
Comment actions Permalink

Hi,

1. Support floating point values was added in TeamCity 9.0 version
2. If build fail condition is configured as follows: build metric has changed comparing to a last successful/finished/pinned build, then the build from the same branch is used. If there is no suitable builds on the same branch, then build from default branch is used and the corresponding message is added to the build log. I have updated the documentation.

0
Comment actions Permalink

Thanks for the reply.  This is the information that I was looking for and how I was hoping it was implmented.  Thanks!

0
Comment actions Permalink

Hi Alina,

I have a follow-up question regarding build failure conditions.  We are using git-flow and hit the case where the first build of a feature branch reported that it was unable to find the last successful build for custom metric comparison.  Since there was no previous build for this branch, I expected it to compare the build metrics to the last successful build on the default branch, per the updated documentation.  I also expected a note in the log file.

But this did not appear to happen.  Here is the relevant snippet from the build logs:

[12:42:32]Cannot find Last successful build, branch: 'feature/MRMS-135' to calculate metric 'Build metric for unique violations in cpp files.' for branch feature/MRMS-135
[12:42:32]Cannot calculate build metric 'very important data' for anchor build #156
[12:42:32]Cannot find Last successful build, branch: 'feature/MRMS-135' to calculate metric 'Build metric for percent violations in cpp files.' for branch feature/MRMS-135



Any idea why this may be the case?

Thanks,

Brian

0
Comment actions Permalink

Hi Brain,

These warnings are OK, they indicate that the value couldn't be find from the original branch. And it means that the value was taken from the default branch.
If you think that the message is not clear enough, please feel free to create an issue in our tracker.

0

Please sign in to leave a comment.