Reputation: 415
Jenkins log parser plugin to make job unstable when below string found in the jenkins console
Below two regex expressions are from a file. which tells if it finds "unknown command" or "WARNING" consider those as warning.
warning /unknown command/
warning /(?i)\bwarning\b/i
How to ignore if we find "unknown command" and WARNING in below context. In Combinations
[exec] ORA-0042: unknown command ")" - rest of line ignored.
[deployComposite] WARNING: Error in applying config plan: Namespace prefix 'ui' used but not declared.. Config plan was skipped.
pls help in two difference regex expression.
Also is there a regex tool I can use to get help from
Thanks in advance
Upvotes: 0
Views: 1220
Reputation: 10509
To match across multiple lines, you need to
unknown command
\n
after that, i.e. skip to the next lineWARNING
is found in the next lineRegular Expression
.*unknown command[^\n]*\n(?![^\n]*WARNING)
Here's some Java code including your example input to demonstrate:
String value = "[exec] ORA-0042: unknown command \")\" - rest of line ignored.\n"
+ "[deployComposite] WARNING: Error in applying config plan: Namespace prefix "
+ "'ui' used but not declared.. Config plan was skipped.";
Pattern pattern = Pattern.compile(".*unknown command[^\n]*\n(?![^\n]*WARNING)");
Matcher matcher = pattern.matcher(value);
if (matcher.find()) {
System.out.println("Matched: " + matcher.group(0));
} else {
System.out.println("No match!");
}
This will output:
No match!
If you now for example change the string WARNING
to DEBUG
, the output will be:
Matched: [exec] ORA-0042: unknown command ")" - rest of line ignored.
Upvotes: 1