Skip to content

Instantly share code, notes, and snippets.

@tszpinda
Last active January 6, 2016 09:36
Show Gist options
  • Save tszpinda/9cf892ff389690169ca2 to your computer and use it in GitHub Desktop.
Save tszpinda/9cf892ff389690169ca2 to your computer and use it in GitHub Desktop.
jenkins count text in console
def jobNameStartsWith = 'EPC-1426-single-version'
def textToMatch = "Total time"
Jenkins.instance.items.findAll { it.displayName.startsWith(jobNameStartsWith) }
.each { job ->
if(job.builds) {
def build = job.isBuilding() ? job.builds[1] : job.builds[0]
def log = build.logFile.text
def regexPattern = "(?i).*${textToMatch}.*"
def summary = log =~ /${regexPattern}/
println "${summary.size()}: $job.displayName"
}
}
return ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment