2

I am trying to search thru log files to see if any warnings have appeared so that I can warn in a Jenkins pipeline using Jenkins plug in "Text Finder".

However, I have a case where I do not want hits on the string "CRIT" int he logfile if the string also contains plms.

E.g. I have the following text in the log file:

<CRIT> 23-Jun-2014::10:57:13.649 Upgrade committed
<CRIT> 23-Jun-2014::10:57:13.703 no registration found for callpoint plmsView/get_next of type=external

I am not interested in having a warning for the second line, so I have added the following regex to Text Finder in Jenkins:

WARN|ERROR|<ERR>|/^(?=<CRIT>)(?=^(?:(?!plms).)*$).*$/

This should get a hit on CRIT only if the string does not also contain plms, i.e the first line, but I do not get a hit on either line.

I got the code from here: Combine Regexp

Could someone please help me correct this? Thanks!

Community
  • 1
  • 1
mammaMia
  • 35
  • 1
  • 7

2 Answers2

1

You should use something like this:

WARN|ERROR|<ERR>|<CRIT>(?!.*?no registration found)

Change the no registration found part to match the <CRIT> message you want to exclude.

This expression matches also for the line:

<INFO> User WARNER registered

so you should consider using something like:

^(WARN|ERROR|<ERR>|<CRIT>(?!.*?no registration found))

that matches only if the tokens are at the beginning of the line (change the tokens accordingly).

enrico.bacis
  • 30,497
  • 10
  • 86
  • 115
0

This should work for you:

^<CRIT>(.(?!plms))*$

Demo and explanation

Dhrubajyoti Gogoi
  • 1,265
  • 10
  • 18