Skip to content

Instantly share code, notes, and snippets.

@matthiasbaldi
Created September 20, 2016 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthiasbaldi/52028924fdecf3f69ac8e733a9e1bd5e to your computer and use it in GitHub Desktop.
Save matthiasbaldi/52028924fdecf3f69ac8e733a9e1bd5e to your computer and use it in GitHub Desktop.
Jenkins Matching Helper for other Jenkins Groovy Scripts
// please set the variable value
def partOfJobNameToSearch = "" // set a part of the job name to generate the list of jobs
// script - here you have nothing to edit
def totCounter = 0
def okCounter = 0
def badCounter = 0
for (item in Jenkins.instance.items) {
totCounter++
if (item.name.toLowerCase().contains(partOfJobNameToSearch.toLowerCase())) {
okCounter++
println("[MATCHED] " + item.name)
} else {
badCounter++
}
}
println("---------------------------------")
println("total: ": + totCounter)
println("matched: " + okCounter)
println("not matched: " + badCounter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment