Skip to content

Instantly share code, notes, and snippets.

@tizki
Last active September 7, 2016 18:52
Show Gist options
  • Save tizki/1224b1859db4be103674d4d09f11d164 to your computer and use it in GitHub Desktop.
Save tizki/1224b1859db4be103674d4d09f11d164 to your computer and use it in GitHub Desktop.
This script shows how to get basic information about a job and its builds
/*This script shows how to get basic information about a job and its builds*/
def jenkins = Jenkins.getInstance()
def jobName = "myJob"
def job = jenkins.getItem(jobName)
println "Job type: ${job.getClass()}"
println "Is building: ${job.isBuilding()}"
println "Is in queue: ${job.isInQueue()}"
println "Last successfull build: ${job.getLastSuccessfulBuild()}"
println "Last failed build: ${job.getLastFailedBuild()}"
println "Last build: ${job.getLastBuild()}"
println "All builds: ${job.getBuilds().collect{ it.getNumber()}}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment