Skip to content

Instantly share code, notes, and snippets.

@icybin
Last active September 7, 2019 05:32
Show Gist options
  • Save icybin/9e7022f10d2ffc42cf69675dedcecca1 to your computer and use it in GitHub Desktop.
Save icybin/9e7022f10d2ffc42cf69675dedcecca1 to your computer and use it in GitHub Desktop.
Jenkins: Print last build information for all jobs
// 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