Skip to content

Instantly share code, notes, and snippets.

@k9ert
Created June 24, 2014 22:11
Show Gist options
  • Save k9ert/3e6d64f620b0254d4ad7 to your computer and use it in GitHub Desktop.
Save k9ert/3e6d64f620b0254d4ad7 to your computer and use it in GitHub Desktop.
example for a Pre-send Script in the JENKINS/Email-ext+plugin
// https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin
// An example for a Pre-send Script
// Assume output log-output like:
// ERROR: [email protected] 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