Reputation: 105
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:
what is the proper way to exclude certain words defined by me?
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)
Upvotes: 4
Views: 5356
Reputation: 5271
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.
Upvotes: 4