| 1 package hudson.maven.reporters; 2 3 import hudson.maven.MavenReporter; 4 import hudson.maven.MavenReporterDescriptor; 5 import hudson.maven.MavenBuildProxy; 6 import hudson.maven.MavenBuild; 7 import hudson.maven.MavenBuildProxy.BuildCallable; 8 import hudson.tasks.Mailer; 9 import hudson.tasks.MailSender; 10 import hudson.model.BuildListener; 11 import org.kohsuke.stapler.StaplerRequest; 12 import org.apache.maven.project.MavenProject; 13 14 import java.io.IOException ; 15 16 19 public class MavenMailer extends MavenReporter { 20 23 public String recipients; 24 public boolean dontNotifyEveryUnstableBuild; 25 public boolean sendToIndividuals; 26 27 28 public boolean postBuild(MavenBuildProxy build, MavenProject pom, final BuildListener listener) throws InterruptedException , IOException { 29 build.execute(new BuildCallable<Void ,IOException >() { 30 public Void call(MavenBuild build) throws IOException , InterruptedException { 31 new MailSender(recipients,dontNotifyEveryUnstableBuild,sendToIndividuals).execute(build,listener); 32 return null; 33 } 34 }); 35 return true; 36 } 37 38 public DescriptorImpl getDescriptor() { 39 return DescriptorImpl.DESCRIPTOR; 40 } 41 42 public static final class DescriptorImpl extends MavenReporterDescriptor { 43 public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl(); 44 45 private DescriptorImpl() { 46 super(MavenMailer.class); 47 } 48 49 public String getDisplayName() { 50 return "E-mail Notification"; 51 } 52 53 public String getHelpFile() { 54 return "/help/project-config/mailer.html"; 55 } 56 57 @Override  59 public String getConfigPage() { 60 return getViewPage(Mailer.class,"config.jelly"); 61 } 62 63 public MavenMailer newInstance(StaplerRequest req) { 64 MavenMailer m = new MavenMailer(); 65 req.bindParameters(m,"mailer_"); 66 return m; 67 } 68 } 69 70 private static final long serialVersionUID = 1L; 71 } 72 | Popular Tags |