Is there a way to retrieve a list of individuals who broke the build in Jenkins Pipeline, just like the mailer plugin apparently does to send out a mail to those involved?
I've found one possible way, though it is somewhat limited to the amount of builds that are being kept. By iterating over the previousBuild hierarchy and their change logs, this may be a solution:
def getAuthors(def build) {
def userIds = []
build.changeSets.each { hudson.scm.SubversionChangeLogSet changeLogSet ->
userIds += changeLogSet.collect { it.author.id }
}
userIds.unique()
}
def getIndividualsWhoBrokeTheBuild() {
def userIds = []
for(def build = currentBuild; build.result != 'SUCCESS'; build = build.previousBuild) {
userIds += getAuthors(build)
}
userIds.unique()
}
Suppose a job keeps only five builds, this won't return the original felon, if it was broken more than five builds before.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With