Child pages
  • Find builds currently running that has been executing for more than N seconds

Due to some maintenance issues, this service has been switched in read-only mode, you can find more information about the why

and how to migrate your plugin documentation in this blogpost

Skip to end of metadata
Go to start of metadata
int MAX_ALLOWED_DURATION_IN_SECONDS = 3600 * 6 // 6 hours


  def busyExecutors = Jenkins.instance.computers
                                .collect { 
                                  c -> c.executors.findAll { it.isBusy() }
                                }
                                .flatten() // reminder: transforms list(list(executor)) into list(executor)

def ok = true

println "Busy Executors list"
busyExecutors.each { e -> 
  println e ; 
  int durationInSeconds = (System.currentTimeMillis() - e.executable.getTimeInMillis())/1000.0
  
  if(durationInSeconds > MAX_ALLOWED_DURATION_IN_SECONDS )
  {
    ok = false;
  }
  println "\t duration=$durationInSeconds"
  println "" 
}

println "Done"

return ok
  • No labels