Skip to content
Latchkey

TeamCity build failed by a metric threshold failure condition in CI

A build metric failure condition compared a metric (artifact size, number of tests, build duration, or a custom metric) against a threshold and failed the build because it crossed the limit or changed too much from a reference build.

What this error means

The build fails with "Failure condition: build metric ... exceeds threshold" naming the metric and the limit, such as artifact size or the number of passed tests.

TeamCity
Build failed. Failure condition:
build metric "artifact size" (120 MB) exceeds the threshold (100 MB)

Common causes

A metric genuinely crossed the threshold

Artifacts grew, tests dropped, or duration rose past the configured limit, which the failure condition treats as a regression.

A threshold set too tightly for normal variation

A metric condition with no tolerance flags routine variation as a failure.

How to fix it

Investigate the metric change

  1. Open the failure condition to see the metric and the threshold or reference build it compares against.
  2. If the change is a real regression (bigger artifacts, fewer tests), address the cause in the build.
  3. If the variation is expected, widen the threshold or compare against a rolling reference.

Adjust the metric failure condition

In Failure Conditions, set a sensible absolute limit or a percentage change from a reference build so normal variation does not fail the build.

How to prevent it

  • Set metric thresholds with tolerance for normal variation.
  • Compare against a rolling reference rather than a single old build.
  • Alert on metric drift before it becomes a hard failure.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →