简体   繁体   中英

Jenkins Log Parser rules

I am using the Jenkins Log Parser Plugin as a post-build step to check for errors after builds

I have all my rules in a file and the notation supports the Java regex embedded flag expression:

# 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).

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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