Skip to content

Instantly share code, notes, and snippets.

@irons
Created July 10, 2014 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save irons/09090503150e119f7096 to your computer and use it in GitHub Desktop.
Save irons/09090503150e119f7096 to your computer and use it in GitHub Desktop.
import jenkins.model.Jenkins
Jenkins.instance.getTrigger("SCMTrigger").getRunners().each()
{
item ->
println(item.getTarget().name)
println(item.getDuration())
println(item.getStartTime())
long millis = Calendar.instance.time.time - item.getStartTime()
if(millis > (1000 * 60 * 3)) // 1000 millis in a second * 60 seconds in a minute * 3 minutes
{
Thread.getAllStackTraces().keySet().each()
{
tItem ->
if (tItem.getName().contains("SCM polling") && tItem.getName().contains(item.getTarget().name))
{
println "Interrupting thread " + tItem.getName();
tItem.interrupt()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment