Skip to content

Instantly share code, notes, and snippets.

@tizki
Created September 7, 2016 19:38
Show Gist options
  • Save tizki/5c2e590164f11bec7feb5eb460fe8cbc to your computer and use it in GitHub Desktop.
Save tizki/5c2e590164f11bec7feb5eb460fe8cbc to your computer and use it in GitHub Desktop.
This scripts shows how to get and print basic information about a specific build
/* This scripts shows how to get and print basic information about a specific build */
def jenkins = Jenkins.getInstance()
def jobName = "myJob"
int buildNumber = 186
def job = jenkins.getItem(jobName)
//get the build
def bld = job.getBuildByNumber(buildNumber)
//print some of the builds info
println "Build type: ${bld.getClass()}"
println "Is buidling: ${bld.isBuilding()}"
println "Build URL: ${bld.getUrl()}"
println "Build result: ${bld.getResult()}"
//println "Environment variables for that build: ${bld.getEnvironment(null)}"
println "Build log: ${bld.getLog()}"
println "Build artifact: ${bld.getArtifacts()}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment