Created
January 22, 2015 18:39
-
-
Save dnozay/898b05f6ee32151b78f3 to your computer and use it in GitHub Desktop.
jenkins - scan jobs and find if last build was aborted (e.g. maintenance) and who aborted it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// scan all jobs and check if the last build was aborted (e.g. maintenance) | |
// and output user / timestamp | |
jobs = Jenkins.instance.getAllItems() | |
lastabort = null | |
jobs.each { j -> | |
if (j instanceof com.cloudbees.hudson.plugins.folder.Folder) { return } | |
numbuilds = j.builds.size() | |
if (numbuilds == 0) { return } | |
lastbuild = j.builds[numbuilds - 1] | |
if (lastbuild.result == Result.ABORTED) { | |
println 'JOB: ' + j.name | |
abortCause = lastbuild.getAction(InterruptedBuildAction).getCauses()[0] | |
println ' -> lastbuild: ' + lastbuild.displayName + ' = ' + lastbuild.result + ', cause: ' + abortCause.shortDescription + ', time: ' + lastbuild.timestampString2 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment