詹金斯日志解析器

Jenkins Log Parser

我在 freestyle Jenkins Jobs 中使用 https://plugins.jenkins.io/log-parser/ 插件。但是自从转向 Jenkins Pipeline 之后,我一直无法将日志解析器集成到 Declaratinve Pipeline 语法中。

如何做到这一点?我也没有在他们的文档中找到信息。另外,什么是好的日志解析规则以及在哪里指定它?也在 Jenkinsfile 中?你能举个例子吗?谢谢

我不使用 log-parser,但快速 glance at the issues 表明它目前不兼容;

JENKINS-27208: Make Log Parser Plugin compatible with Workflow

JENKINS-32866: Log Parser Plugin does not parse Pipeline console outputs

更新:
这个 by Jesse Glick (Cloudbees; Jenkins sponsor) to similar question suggests it does in fact work now and suggests how to generate syntax, but OP complains DSL and documentation is weak.

gdemengin 写道 pipeline-logparser to work around another issue JENKINS-54304

Build Failure Analyzer可能对你也有用。 YMMV

您可以尝试以下操作:

stage('check') {
  steps {
    echo 'checking logs from previous stages...'
    logParser failBuildOnError: true, parsingRulesPath: '/path/to/rules', useProjectRule: false, projectRulePath: ''
    }
}

Jenkins 中的 pipeline syntax 部分允许您获取 Jenkinsfile 的片段