Skip to content

Instantly share code, notes, and snippets.

@tszpinda
Created January 6, 2016 10:34
Show Gist options
  • Save tszpinda/61a40e063107313361c4 to your computer and use it in GitHub Desktop.
Save tszpinda/61a40e063107313361c4 to your computer and use it in GitHub Desktop.
Jenkins count flaky tests
import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*
def jobNameStartsWith = 'EPC-1426'
def textToMatch = "Flakes"
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