Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save icy/d0ef22495bbe5afbb98585ff2046c752 to your computer and use it in GitHub Desktop.
Save icy/d0ef22495bbe5afbb98585ff2046c752 to your computer and use it in GitHub Desktop.
jenkins_script_print_last_builds_for_all_jobs.groovy
// Author : Ky-Anh Huynh
// License: MIT
// Origin : https://gist.github.com/dnozay/e7afcf7a7dd8f73a4e05#file-disk-usage-retention-groovy
jobs = Jenkins.instance.getAllItems()
jobs.each { j ->
if (j instanceof com.cloudbees.hudson.plugins.folder.Folder) { return }
if (j instanceof jenkins.branch.OrganizationFolder) { return }
if (j instanceof org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject) { return }
numbuilds = j.builds.size()
println 'JOB: ' + j.fullName
if (numbuilds == 0) {
println ' -> no build'
} else {
lastbuild = j.builds[numbuilds - 1]
println ' -> lastbuild: ' + lastbuild.displayName + ' = ' + lastbuild.result + ', time: ' + lastbuild.timestampString2
}
}
''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment