简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM