Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search through console output of a Jenkins job

Tags:

I have a Jenkins job with 100+ builds. I need to search through all the builds of that job to find builds that have a certain string in the console output. Is there any plugin for that? How do I do that?

like image 938
user1550159 Avatar asked Mar 23 '16 20:03

user1550159


1 Answers

I often use the Jenkins Script Console for tasks like this. The Groovy plugin provides the Script Console, but if you're going to use the Script Console for periodic maintenance, you'll also want the Scriptler plugin which allows you to manage the scripts that you run.

From Manage Jenkins -> Script Console, you can write a groovy script that iterates through the job's builds looking for the matching string:

JOB_NAME = "My Job" BUILD_STRING = "Hello, world"  def job = Jenkins.instance.items.find { it.name == JOB_NAME } for (build in job.builds) {   def log = build.log   if (log.contains(BUILD_STRING)) {     println "${job.name}: ${build.id}"   } } 
like image 65
Dave Bacher Avatar answered Sep 21 '22 20:09

Dave Bacher