Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ffledgling/4b29814d343300da750656e6ce29d288 to your computer and use it in GitHub Desktop.
Save ffledgling/4b29814d343300da750656e6ce29d288 to your computer and use it in GitHub Desktop.
Groovy script for use with Jenkins to get builds of jobs that were run with a a certain parameter set to a certain value.
//def hi = hudson.model.Hudson.instance
// Just use Jenkins.instance, it's the same thing
def ji = Jenkins.instance
def param_name = "GERRIT_REFSPEC"
def job_pattern = /.*/ //Job Name pattern, used to select jobs we want to select
def param_value_filter = /.*/ // Pattern to select values of
def matchedJobs = ji.items.findAll { job ->
job.name =~ job_pattern
}
matchedJobs.each {
allBuilds = it.getBuilds()
jobName = it.fullName
allBuilds.each {
def param_val = it.buildVariableResolver.resolve(param_name)
if (param_val =~ param_value_filter) {
println it.url + ' ' + param_val
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment