I have to read the jenkins console output and grep the line which has the string "%)"
. I am able to grep the line wit the following code:
def result = fileContents.findAll { it.contains('%)') }
println result*.toString()
Output:
× 35 of 45 failed (78%) 06:13 247 3 38 66 140
From the above line, I need to fetch and print only failed %. ie. 78 and make the Jenkins job failed if the failed % is above 50%
Can someone please help me with this using Groovy? Is there any other way to do it without using Groovy also fine for me?
According to me, instead of having the groovy script do this for you (complicated way), follow the below steps:
wget <jenkins_url_of_console_output>
In you case, you can take the percentage success/failure and pass/fail the stage according to your requirement. Hope this helps.