Print the line if it contains a specific string by using groovy

0 votes

I am having a Jenkins log file and I am trying to print those lines which are having string "FOUND" in it.

How do I write the code for it in Groovy as I am new to it? Can anyone help me with this?

Thanks.

Apr 27, 2018 in Jenkins by Atul
• 10,240 points
30,231 views

1 answer to this question.

0 votes

You can try the code written below:

def lines = new File('/tmp/test123.txt').readLines()
def result = lines.findAll { it.contains('FOUND') }
println result*.toString()

I hope that it will resolve your query. 
answered Apr 27, 2018 by shubham
• 7,340 points

Related Questions In Jenkins

+1 vote
1 answer
0 votes
2 answers
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,034 views
+2 votes
1 answer
0 votes
1 answer
+2 votes
5 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP