-
-
Save farazxameer/cc5ce4e262898f4219d5e013d3b6c2b6 to your computer and use it in GitHub Desktop.
example for a Pre-send Script in the JENKINS/Email-ext+plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin | |
// An example for a Pre-send Script | |
// Assume output log-output like: | |
// ERROR: yourmail@company.com please fix | |
import javax.mail.internet.* | |
logger.print("This ends up in the log as well"); | |
String encodingOptions = "text/html; charset=UTF-8;"; | |
// msg.setContent("please check!!!!", encodingOptions); | |
build.getLog(1000).each() { line -> | |
if (line.contains("ERROR")) { | |
if (line.contains("please fix")) { | |
matcher = (line =~ /ERROR: (.*) please fix/); | |
if (matcher.matches()) { | |
msg.addRecipient(javax.mail.Message.RecipientType.TO, new javax.mail.internet.InternetAddress(matcher[0][1])) | |
logger.print("sending message to "+matcher[0][1]); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment