I am new to Groovy and am trying to set up a postbuild in Jenkins that allows me to count strings and determine if the build succeeded by how many the count returns at the e
manager.build.logFile.text
returns the whole file text as String.
What you need is readLines()
:
def list = manager.build.logFile.readLines()
def JobCount = list.count {it.startsWith("====") && it.contains("COMPLETE")}
and of course as mentioned below, the Jenkins Groovy Postbuild plugin runs Groovy scripts, so you will have get rid of the enclosing class declaration (Main
)