File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\maven-plugin\src\main\java\hudson\maven\reporters\MavenMailer.java.html

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Bruce Chapman
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 package hudson.maven.reporters;
25
26 import hudson.Launcher;
27 import hudson.Extension;
28 import hudson.maven.MavenBuild;
29 import hudson.maven.MavenReporter;
30 import hudson.maven.MavenReporterDescriptor;
31 import hudson.model.BuildListener;
32 import hudson.tasks.MailSender;
33 import hudson.tasks.Mailer;
34 import org.kohsuke.stapler.StaplerRequest;
35
36 import java.io.IOException;
37
38 import net.sf.json.JSONObject;
39
40 /**
41 * Sends out an e-mail notification for Maven build result.
42 * @author Kohsuke Kawaguchi
43 */
44 public class MavenMailer extends MavenReporter {
45 /**
46 * @see Mailer
47 */
48 public String recipients;
49 public boolean dontNotifyEveryUnstableBuild;
50 public boolean sendToIndividuals;
51 public boolean perModuleEmail;
52
53 public boolean end(MavenBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
54 if(perModuleEmail) {
55 new MailSender(recipients,dontNotifyEveryUnstableBuild,sendToIndividuals).execute(build,listener);
56 }
57 return true;
58 }
59
60 @Extension
61 public static final class DescriptorImpl extends MavenReporterDescriptor {
62 public String getDisplayName() {
63 return Messages.MavenMailer_DisplayName();
64 }
65
66 public String getHelpFile() {
67 return "/help/project-config/mailer.html";
68 }
69
70 // reuse the config from the mailer.
71 @Override
72 public String getConfigPage() {
73 return getViewPage(Mailer.class,"config.jelly");
74 }
75
76 public MavenReporter newInstance(StaplerRequest req, JSONObject formData) throws FormException {
77 MavenMailer m = new MavenMailer();
78 req.bindParameters(m,"mailer_");
79 m.dontNotifyEveryUnstableBuild = req.getParameter("mailer_notifyEveryUnstableBuild")==null;
80 m.perModuleEmail = req.hasParameter("maven.perModuleEmail");
81 return m;
82 }
83 }
84
85 private static final long serialVersionUID = 1L;
86 }
87