Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #6 from mrebasti/jenkins-16522
[FIXED JENKINS-16522] Wrong status for maven submodule
  • Loading branch information
olamy committed Oct 18, 2013
2 parents 11b05a7 + a5714f3 commit 6f80083
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 14 deletions.
7 changes: 0 additions & 7 deletions src/main/java/hudson/maven/Maven3Builder.java
Expand Up @@ -165,13 +165,6 @@ public Result call() throws IOException {
return Result.SUCCESS;
}

if(markAsSuccess) {
logger.println(Messages.MavenBuilder_Failed());
if(mavenExecutionListener.hasTestFailures()){
return Result.UNSTABLE;
}
return Result.SUCCESS;
}
return Result.FAILURE;
} catch (NoSuchMethodException e) {
throw new IOException2(e);
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/hudson/maven/MavenBuilder.java
Expand Up @@ -179,13 +179,6 @@ public Result call() throws IOException {
return Result.SUCCESS;
}

if(markAsSuccess) {
listener.getLogger().println(Messages.MavenBuilder_Failed());
if(a.hasBuildFailures()){
return Result.UNSTABLE;
}
return Result.SUCCESS;
}
return Result.FAILURE;
} catch (NoSuchMethodException e) {
throw new IOException2(e);
Expand Down Expand Up @@ -305,6 +298,12 @@ public void preBuild(MavenSession session, ReactorManager rm, EventDispatcher di

public void postBuild(MavenSession session, ReactorManager rm, EventDispatcher dispatcher) throws BuildFailureException, LifecycleExecutionException, IOException, InterruptedException {
long startTime = System.nanoTime();
// If postModule wasn't executed before this method, the build has failed.
if (lastModule != null) {
ModuleName name = new ModuleName(lastModule);
MavenBuildProxy2 proxy = listener.proxies.get(name);
proxy.setResult(Result.FAILURE);
}
fireLeaveModule();
listener.postBuild(session, rm, dispatcher);
overheadTime += System.nanoTime()-startTime;
Expand Down
28 changes: 28 additions & 0 deletions src/test/java/hudson/maven/MavenBuildTest.java
@@ -1,6 +1,7 @@
package hudson.maven;

import hudson.Launcher;
import hudson.model.BallColor;
import hudson.model.BuildListener;
import hudson.model.ParametersDefinitionProperty;
import hudson.model.Result;
Expand Down Expand Up @@ -191,6 +192,33 @@ public void testExtensionsConflictingWithCore() throws Exception {
buildAndAssertSuccess(m);
}

/**
* This tests build a project with two modules. One that have tests failures
* and the other don't compile due to a missing dependency.
*
* @throws Exception
*/
@Bug(16522)
public void testCorrectModuleBuildStatus() throws Exception {
MavenModuleSet mavenProject = createMavenProject();
MavenInstallation mavenInstallation = configureDefaultMaven();
mavenProject.setMaven(mavenInstallation.getName());
mavenProject.setScm(new ExtractResourceSCM(getClass().getResource("JENKINS-16522.zip")));
mavenProject.setGoals( "clean install" );
MavenModuleSetBuild build = mavenProject.scheduleBuild2(0).get();

assertBuildStatus(Result.FAILURE, build);

MavenModule moduleA = mavenProject.getModule("org.marcelo$moduleA");
assertNotNull(moduleA);
assertEquals(BallColor.YELLOW, moduleA.getIconColor());

MavenModule moduleB = mavenProject.getModule("org.marcelo$moduleB");
assertNotNull(moduleB);
assertEquals(BallColor.RED, moduleB.getIconColor());

}

private static class TestReporter extends MavenReporter {
private static final long serialVersionUID = 1L;

Expand Down
Binary file added src/test/resources/hudson/maven/JENKINS-16522.zip
Binary file not shown.

0 comments on commit 6f80083

Please sign in to comment.