Skip to content

Commit

Permalink
Fixes JENKINS-24832 : Failed maven builds using -T are showing up as …
Browse files Browse the repository at this point in the history
…Aborted (#79)
  • Loading branch information
aheritier committed Sep 22, 2016
1 parent c10cfb4 commit 2e671da
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/main/java/hudson/maven/MavenModuleSetBuild.java
Expand Up @@ -221,19 +221,29 @@ public Result getResult() {

private Result computeResult() {
Result r = super.getResult();

if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("Current result is: " + r);
}
for (MavenBuild b : getModuleLastBuilds().values()) {
Result br = b.getResult();
if(r==null)
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("Module result is: " + br + " for " + b.getParent().getGroupId() + ":" +
b.getParent().getArtifactId());
}
if (r == null) {
r = br;
else
if(br==Result.NOT_BUILT)
} else if (br == Result.NOT_BUILT || br == Result.ABORTED) {
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("Result not updated: " + r);
}
continue; // UGLY: when computing combined status, ignore the modules that were not built
else
if(br!=null)
} else if (br != null) {
r = r.combine(br);
}
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("New result is: " + r);
}
}

return r;
}

Expand Down
16 changes: 16 additions & 0 deletions src/test/java/hudson/maven/MavenMultiModuleTest.java
Expand Up @@ -37,6 +37,7 @@
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.ToolInstallations;

Expand Down Expand Up @@ -505,6 +506,21 @@ else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:modul
assertEquals(expected, TestAM.archivings);
}

@Issue("JENKINS-24832")
@Test
public void testMultiModulesFailureWithParallelThreads() throws Exception {
ToolInstallations.configureMaven3();
MavenModuleSet project = j.createProject(MavenModuleSet.class, "mp");
project.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimod-failure.zip")));
// Without the parallel option it is correctly failing
project.setGoals("test");
j.assertBuildStatus(Result.FAILURE, project.scheduleBuild2(0).get());
// With the parallel option it was previously reported as aborted
project.setGoals("test -T 2");
j.assertBuildStatus(Result.FAILURE, project.scheduleBuild2(0).get());
}


public static final class TestAMF extends ArtifactManagerFactory {
@Override public ArtifactManager managerFor(Run<?,?> build) {
return new TestAM(build);
Expand Down
Binary file not shown.

0 comments on commit 2e671da

Please sign in to comment.