fixed a bug where e-mail notification wasn't working with the native m2 project.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@2511 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2007-03-14 01:53:11 +00:00
1 parent eeb9da761b
commit 13da5b56a9
3 files changed
+37 -15

No files matched your search

@@ -186,9 +186,10 @@ public class MavenBuild extends AbstractBuild<MavenModule,MavenBuild> {
}
private class RunnerImpl extends AbstractRunner {
private List<MavenReporter> reporters = new ArrayList<MavenReporter>();
protected Result doRun(BuildListener listener) throws Exception {
// pick up a list of reporters to run
List<MavenReporter> reporters = new ArrayList<MavenReporter>();
getProject().getReporters().addAllTo(reporters);
for (MavenReporterDescriptor d : MavenReporters.LIST) {
if(getProject().getReporters().contains(d))
@@ -269,6 +270,17 @@ public class MavenBuild extends AbstractBuild<MavenModule,MavenBuild> {
}
public void post(BuildListener listener) {
try {
for (MavenReporter reporter : reporters)
reporter.end(MavenBuild.this,launcher,listener);
} catch (InterruptedException e) {
e.printStackTrace(listener.fatalError("aborted"));
setResult(Result.FAILURE);
} catch (IOException e) {
e.printStackTrace(listener.fatalError("failed"));
setResult(Result.FAILURE);
}
if(!getResult().isWorseThan(Result.UNSTABLE)) {
// trigger dependency builds
DependencyGraph graph = Hudson.getInstance().getDependencyGraph();
@@ -1,11 +1,14 @@
package hudson.maven;
import hudson.ExtensionPoint;
import hudson.Launcher;
import hudson.model.Action;
import hudson.model.BuildListener;
import hudson.model.Describable;
import hudson.model.Project;
import hudson.model.Build;
import hudson.tasks.BuildStep;
import hudson.tasks.Publisher;
import org.apache.maven.project.MavenProject;
import java.io.IOException;
@@ -127,6 +130,9 @@ public abstract class MavenReporter implements Describable<MavenReporter>, Exten
/**
* Called after the actual maven2 execution completed.
*
* <p>
* Note that at this point the build result is still not determined.
*
* @return
* See {@link #preBuild}
* @throws InterruptedException
@@ -138,6 +144,17 @@ public abstract class MavenReporter implements Describable<MavenReporter>, Exten
return true;
}
/**
* Called after the maven execution finished and the result is determined.
*
* <p>
* This method fires after {@link #postBuild(MavenBuildProxy, MavenProject, BuildListener)}.
* Works like {@link Publisher#perform(Build, Launcher, BuildListener)}.
*/
public boolean end(MavenBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
return true;
}
/**
* Equivalent of {@link BuildStep#getProjectAction(Project)}
* for {@link MavenReporter}.
@@ -1,15 +1,14 @@
package hudson.maven.reporters;
import hudson.Launcher;
import hudson.maven.MavenBuild;
import hudson.maven.MavenReporter;
import hudson.maven.MavenReporterDescriptor;
import hudson.maven.MavenBuildProxy;
import hudson.maven.MavenBuild;
import hudson.maven.MavenBuildProxy.BuildCallable;
import hudson.tasks.Mailer;
import hudson.tasks.MailSender;
import hudson.maven.MavenModule;
import hudson.model.BuildListener;
import hudson.tasks.MailSender;
import hudson.tasks.Mailer;
import org.kohsuke.stapler.StaplerRequest;
import org.apache.maven.project.MavenProject;
import java.io.IOException;
@@ -24,14 +23,8 @@ public class MavenMailer extends MavenReporter {
public boolean dontNotifyEveryUnstableBuild;
public boolean sendToIndividuals;
public boolean postBuild(MavenBuildProxy build, MavenProject pom, final BuildListener listener) throws InterruptedException, IOException {
build.execute(new BuildCallable<Void,IOException>() {
public Void call(MavenBuild build) throws IOException, InterruptedException {
new MailSender(recipients,dontNotifyEveryUnstableBuild,sendToIndividuals).execute(build,listener);
return null;
}
});
public boolean end(MavenBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
new MailSender<MavenModule,MavenBuild>(recipients,dontNotifyEveryUnstableBuild,sendToIndividuals).execute(build,listener);
return true;
}