Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How will I filter out only errors in Jenkins-email-ext, BUILD_LOG_REGEX?

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?

like image 479
user1048613 Avatar asked Feb 24 '12 23:02

user1048613


People also ask

How do I get email notifications from Jenkins?

Go to the Jenkins home page and click the 'Manage Jenkins' menu option. Then, select the 'Configure System' option. Enter the SMTP server name under 'Email Notification'. Click the 'Advanced' button and then click the checkbox next to the 'Use SMTP Authentication' option.

Can Jenkins send email on failure?

If the recipient list is empty, then only the individuals will receive e-mails. So we have configured mail notification for build jobs. If there is any failure in build or any changes in build state from failure to success or success to failure, you would get an mail notification.

How do I use editable email notifications in Jenkins?

For a project to use this plugin, you need to enable it in the project configuration page. In the Post-build Actions section, click on Add post-build action and then select Editable Email Notification. There are three main fields that you can edit when this plugin is enabled: Project Recipient List.


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
like image 117
malenkiy_scot Avatar answered Oct 01 '22 02:10

malenkiy_scot