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?


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

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
• 6,910 points

Related Questions In Jenkins

+1 vote
1 answer
0 votes
2 answers
+13 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 26, 2018 in DevOps & Agile by DragonLord999
• 8,420 points
0 votes
1 answer
0 votes
1 answer
+2 votes
5 answers