Skip to content

Instantly share code, notes, and snippets.

@daniilyar
Last active December 20, 2022 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save daniilyar/bcfa3ceb40061c5ee08fe8b907c5e9b1 to your computer and use it in GitHub Desktop.
Save daniilyar/bcfa3ceb40061c5ee08fe8b907c5e9b1 to your computer and use it in GitHub Desktop.
Jenkins groovy script: get all builds started during a specific time
// This example lists all job that were started on Jul 16, 2019 between 1:20 PM and 2:30 PM
String df = 'MMM dd, yyyy h:mm a'
long startTimestamp = Date.parse(df, 'Jul 16, 2019 1:20 PM').getTime()
long endTimestamp = Date.parse(df, 'Jul 16, 2019 2:30 PM').getTime()
Jenkins.instance.getAllItems(AbstractItem.class).each {
builds = it.getBuilds().byTimestamp(startTimestamp, endTimestamp)
if(!builds.isEmpty()) {
println(it.fullName)
println(builds)
}
}
return null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment