TeamCity triggers failure condition which is wrong.

We have set up TeamCity' "failure conditions" to fail build if code coverage metric is bad. The exact condition is to fail build in case code coverage metric has dropped down by several percents.

Sometimes we build a branch which is building for the first time. These are basically release branches. We build them once.

The problem is that TeamCity fails while building new branches. It says, code coverage is bad. 

In logs I see that TeamCity cannot find previous build for my branch. Indeed,  it needs some previous build to compare code coverage and cannot find it because the branch is new. And as a result it is using some "anchor" branch for comparison.

"Anchor" branch is some old outdated branch which has bigger code coverage. So the evaluation of condition is correct. 

The problem is that in case I am building a first build of some branch I expect one of the folowing behaviours:

1. disable code coverage metrics which need previous build which is missing

2. use some meaningfull "anchor" build to compare with, not some outdated build selected by some unclear to me way.

How can I fix it?

Comment actions Permalink

Hello Dmitry,

At the moment TeamCity uses the following logic:

  • build metrics take into account the running build's branch and choose a build from the same branch to compare with. 
  • if such a build does not exist, the build from the <default> branch is considered.

As workaround you can run build on default branch with smaller code coverage. Another option is to create new build configuration per branch. In this case the build report "Cannot find Latest successful build to calculate metric" and does not fail.

We have the related request:, please vote for it.

Comment actions Permalink

Alina, thanks for explanations! Thats adds some understanding.

Now I can rebuild default (or some other temporary default) branch to get apporpriate code coverage for history.

One thing is left - it was described in another question of me ( It is that when I change default branch that settings are not applied immediately and I dont understand when they will be applied.

I.e. I have done the following:

1. changed default branch

2. removed old branch settings from Branch specification editBox

And when I re-run the build - it still gets stats from old default branch.

Moreover, when I try to select specific branch for build by pressing (...) buttin near Run button - it doesn't allow me to select branches I have placed in Branch specification. It still shows old branches. After the update hours have passed.




Please sign in to leave a comment.