13

I am looking for a way to fail a build if it will take more than X time (be it absolute (5 minutes -- example) or relative (10% more than the average of the last 5 builds -- example).

Is there any plugin to do that or should I build such functionality onto my running scripts?

I've been searching for plugins but couldn't find one that will mark a build as fail, only report build times.

Daniel
  • 337
  • 1
  • 2
  • 6
  • 1
    Maybe https://wiki.jenkins-ci.org/display/JENKINS/Build-timeout+Plugin –  Dec 02 '16 at 19:56

2 Answers2

9

There is a build timeout plugin:

This plugin allows you to automatically abort a build if it's taking too long. Once the timeout is reached, Jenkins behaves as if an invisible hand has clicked the "abort build" button.

alecxe
  • 11,425
  • 10
  • 49
  • 107
Michael Durrant
  • 25,210
  • 3
  • 40
  • 112
  • I have totally overlooked the fact that this plugin can actually mark the build as failed (the description and docs only talk about 'abort'). I'll try this one! – Daniel Dec 06 '16 at 16:54
5

A similar question was asked on SO.

You can use a code timeout if your workflow steps are scripts. Otherwise, the Build Timeout plugin might do the trick.

kirbycope
  • 4,090
  • 1
  • 13
  • 30