Skip to content

Instantly share code, notes, and snippets.

@nextrevision
Created November 23, 2016 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nextrevision/5447596a9664f62bf9f80f3600dc860b to your computer and use it in GitHub Desktop.
Save nextrevision/5447596a9664f62bf9f80f3600dc860b to your computer and use it in GitHub Desktop.
Loops through jobs by regex printing the job name and the value of the parameter PARAM1
import jenkins.model.*
def matchedJobs = Jenkins.instance.items.findAll { job ->
job.name =~ /job_regex_here/
}
matchedJobs.each { job ->
def latest = job.getLastSuccessfulBuild()
def name = job.name
// resolve the parameter
def param1 = latest.buildVariableResolver.resolve("PARAM1")
println "${name}:${param1}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment