Skip to content

Instantly share code, notes, and snippets.

@ffledgling
Created March 14, 2017 14:26
Show Gist options
  • Select an option

  • Save ffledgling/c4d9b3818a77f8005b385b705ab3604a to your computer and use it in GitHub Desktop.

Select an option

Save ffledgling/c4d9b3818a77f8005b385b705ab3604a to your computer and use it in GitHub Desktop.
Use this script to check that we managed to modify all of the groovy post build scripts correctly. Search for a pattern in the text of the script. For example to check if a URL was changed correctly, or to make sure there are no jobs with a particular influxdb URL in their postbuild
def ji = Jenkins.instance
def job_pattern = /.*/ //Job Name pattern, used to select jobs we want to select
def script_pattern = /http:\/\/influx.mydomain.com:8086\/write\?db=k8s-vm-parity/
def matchedJobs = ji.items.findAll { job ->
job.name =~ job_pattern
}
matchedJobs.each {
for (publisher in it.publishersList) {
if (publisher instanceof org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder) {
def groovyscript = publisher.script.script
if (!(groovyscript =~ script_pattern)) {
println it.fullName
}
}
}
}
println "done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment