简体   繁体   English

Jenkins Log Parser规则

[英]Jenkins Log Parser rules

I am using the Jenkins Log Parser Plugin as a post-build step to check for errors after builds 我使用Jenkins Log Parser插件作为构建后步骤来检查构建后的错误

I have all my rules in a file and the notation supports the Java regex embedded flag expression: 我在文件中包含了所有规则,并且符号支持Java regex嵌入式标志表达式:

# list keywords or regex for ERRORS:
error /(?i)error/
error / (?i)error/
error /(?i)error /
error / (?i)error /

error /(?i)error:/
error / (?i)error:/
error /(?i)error: /
error / (?i)error: /

error /Unknown database/
error /Connect failed/
error /(?i)undefined/
error /Call Stack:/



# list keywords or regex for WARNINGS:
warning /(?i)^warning/
warning /(?i)warning/
warning /(?i)warning:/

My problem is that I am not so good with regex expressions, and every time it encounters a word that contains "error" it triggers an alarm. 我的问题是我对正则表达式表达不太好,每次遇到包含“错误”的单词时都会触发警报。 For example: T**error** or Biot**error** (and I know it may come from my bad expressions, but if I mark "Bioterror" or "Terror" as warning, it still overwrites them as errors and triggers the alarm). 例如:T **错误**或Biot **错误**(我知道它可能来自我的坏表达,但如果我将“Bioterror”或“Terror”标记为警告,它仍会将其覆盖为错误和触发器闹钟)。

My questions are: 我的问题是:

  1. what is the proper way to exclude certain words defined by me? 排除我定义的某些单词的正确方法是什么?

  2. is this achievable? 这是可以实现的吗? (I thought this is the way the plugin works, since if I mark the necessary words as warnings it still highlights them as errors) (我认为这是插件的工作方式,因为如果我将必要的单词标记为警告,它仍会将它们突出显示为错误)

What you want is a word-boundary anchor, which is \\b in most regex flavors. 你想要的是一个单词边界锚,它在大多数正则表达式中都是\\b It's zero-width, so it doesn't match any character, just the switch from non-word to word characters. 它是零宽度,因此它不匹配任何字符,只是从非字符到字符的切换。

So your match would become: 所以你的比赛将成为:

error /(?i)\\berror\\b/

That one regex handles all the cases it looked like you were trying to handle separately: space before or after, colon after, etc. 那个正则表达式处理你看起来像你试图单独处理的所有情况:前后空间,后面冒号等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM