Created
March 14, 2017 11:20
-
-
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.
This file contains 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
//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