Adding failure conditions for a build in TeamCity

By default, a build fails when either of below things happen.

  1. Build process exits with non-zero code
  2. at least one test fails
  3. Build process crashes

We can edit these settings from failure conditions page as shown in below image.

Build failure conditions in TeamCity

But TeamCity also allows us to add extra failure conditions. There are 2 broad categories of failure conditions that can be added.

  1. Fail when a build log contains specific text
  2. Fail when certain metric condition is met. For example – fail when artifact size more than 1 GB or When build duration is more than 20 minutes.

Below images show how we set up these failure conditions  for a build.

Fail build when specific text is found in log in TeamCity

Fail build when specific text is found in log in TeamCity

 

Fail build on metric change in TeamCity

Fail build on metric change in TeamCity

You may also like...