Currently I m using BUILD_LOG_REGEX in Jenkins Editable email information to get a log of the errors via email. But I get a lot of junk and I want to filter out the errors and I want the log of errors filtered to perfection. Any help?
-
Is there some common string in the error log lines to base your regex on? If not, can you add one? Could you provide an example, which kind of regex you are using, which kind of log lines should be caught and which kind not? – Juuso Ohtonen Feb 25 '12 at 11:19
-
Hey Juuso, I am able to filter one kind of error now. But I would want to filter more than one kind of error. For example, An error log could be of the format Error: (or) [Error] (or) Failed: and so on and so forth. How do I make an or condition in the BUILD_LOG_REGEX ? – user1048613 Feb 27 '12 at 18:33
1 Answers
Your question is rather non-specific. As Juuso Ohtonen notes in a comment, what you do highly depends on what can be usually found in your log. Here's an example of what we use in one of our jobs, it is rather generic (if not to say minimalistic):
${BUILD_LOG_REGEX, regex="^.*?BUILD FAILED.*?$", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true}
I would suggest the following: create a job that logs some text that contains types of errors you encounter (you may just spew some text file that you place in the job's workspace), then play with Java regex patterns - java.util.regex.Pattern - in the Plugin until you get the desired result. Make sure you send the e-mails from the job only to yourself :)
To use custom HTML - here's a quote from the Plugin's Content Token reference:
${JELLY_SCRIPT, template} - Custom message content generated from a Jelly script
template. There are two templates provided: "html" and "text". Custom Jelly templates
should be placed in $JENKINS_HOME/email-templates. When using custom templates, the
template filename without ".jelly" should be used for the "template" argument.
template - the template name. Defaults to "html".
The default template that you can use as your starting point is located in
$JENKINS_HOME/plugins/email-ext/WEB-INF/classes/hudson/plugins/emailext/templates/html.jelly

- 34,866
- 14
- 107
- 142

- 16,415
- 6
- 64
- 87
-
I am giving you some examples of how my log files look like. Well in this case, only the error logs (different kinds of error logs): Case:1 Error: folder mismatch - please check the following files: ============================================================================= Removed: \foo2.cs Removed: \WorkflowsHighAvailabilityApp\Application\WorkflowsHighAvailabilityApp.cs Case:2 – user1048613 Feb 27 '12 at 18:22
-
1My condition looks like this: ${BUILD_LOG_REGEX,regex="Error:",linesBefore=0,linesAfter=5,showTruncatedLines=false} . This filters only logs with Error:, but I want to filter error that has many kinds like [Error]/Failed: , etc. Any suggestions? – user1048613 Feb 27 '12 at 18:35
-
BUILD_LOG_REGEX uses `java.util.regex.Pattern` regular expressions: http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html – malenkiy_scot Feb 27 '12 at 19:11
-
1Ok, I succeeded in filtering the error log as I wanted to using regular expressions. Now is there a way wherein I can format the way this is being displayed? Like putting this log in a table format using HTML? Can I use email-ext plugin to succeed in it? Any example? – user1048613 Feb 27 '12 at 22:26
-
1
-
Note, in the current version of Jenkins with email-ext, curly brace is not the syntax to put into the web form boxes. Use the same but parentheses:
$(BUILD_LOG_REGEX, regex="^.*?BUILD FAILED.*?$", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true)
– AnneTheAgile Feb 02 '15 at 17:53 -