Skip to content

Instantly share code, notes, and snippets.

@aheritier
Created November 21, 2016 17:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aheritier/aed3b0c7098c2f06b8a10ff1e99d44ae to your computer and use it in GitHub Desktop.
Save aheritier/aed3b0c7098c2f06b8a10ff1e99d44ae to your computer and use it in GitHub Desktop.
Find Pipeline Scripts running for more than 1 day
import groovy.time.*
println "List of running jobs : "
use(TimeCategory) {
Jenkins.instance.getAllItems(org.jenkinsci.plugins.workflow.job.WorkflowJob).each{
job -> job.builds.findAll{it.isBuilding() && new Date(it.startTimeInMillis) < (new Date() - 1.day) }.each{
build ->
TimeDuration duration = TimeCategory.minus(new Date(), new Date(build.startTimeInMillis))
println "* $job.fullName#$build.number started since $duration"
}
}
}
return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment