搜索Jenkins作业的控制台输出 [英] Search through console output of a Jenkins job

查看:165
本文介绍了搜索Jenkins作业的控制台输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个拥有100多个版本的Jenkins工作.我需要搜索该作业的所有内部版本,以找到在控制台输出中具有特定字符串的内部版本.是否有任何插件?我该怎么办?

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?

推荐答案

我经常使用 Jenkins脚本控制台,用于执行此类任务. Groovy插件提供了脚本控制台,但是如果您要使用脚本控制台进行定期维护,您还需要 Scriptler插件,使您可以管理所运行的脚本.

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.

Manage Jenkins -> 脚本控制台中,您可以编写一个普通的脚本,该脚本遍历作业的构建以寻找匹配的字符串:

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}"
  }
}

这篇关于搜索Jenkins作业的控制台输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆