Arun
Arun

Reputation: 2092

Log parsing rules in Jenkins

I'm using Jenkins log parser plugin to extract and display the build log. The rule file looks like,

 # Compiler Error
 error /(?i) error:/

 # Compiler Warning
 warning /(?i) warning:/

Everything works fine but for some reasons, at the end of "Parsed Output Console", I see this message,

NOTE: Some bad parsing rules have been found:

Bad parsing rule: , Error:1
Bad parsing rule: , Error:1

This, I'm sure is a trivial issue but not able to figure it out at this moment. Please help :)

EDIT: Based on Kobi's answer and having looked into the "Parsing rules files", I fixed it this way (a single space after colon). This worked perfectly as expected.

# Compiler Error
error /(?i)error: /

# Compiler Warning
warning /(?i)warning: /

Upvotes: 6

Views: 11427

Answers (2)

Aviator
Aviator

Reputation: 107

I had tried no spaces in the pattern, but that did not work. Turns out that the Parsing Rules files does not support empty lines in it. Once I removed the empty lines, I did not get this "Bad parsing rule: , Error:1".

I think since the line is empty - it doesn't echo any rule after the first colon. Would have been nice it the line number was reported where the problem is.

Upvotes: 0

Kobi
Kobi

Reputation: 138087

The Log Parser Plugin does not support spaces in your pattern.

This can be clearly seen in their source code:

final String ruleParts[] = parsingRule.split("\\s");
String regexp = ruleParts[1];

They should probably have used .split("\\s", 2).

As an alternative, you can use \s, \b, or an escape sequence - \u0020.

Upvotes: 6

Related Questions