Skip to content

Commit

Permalink
[JENKINS-34900] getRootBuild() returns itself when there's no parent. (
Browse files Browse the repository at this point in the history
  • Loading branch information
ikedam authored and aheritier committed Aug 26, 2016
1 parent d2554dd commit aacdd9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/hudson/maven/MavenBuild.java
Expand Up @@ -176,11 +176,12 @@ public String getDisplayName() {
}

/**
* The same as {@link #getParentBuild()}.
* The same as {@link #getParentBuild()} except that returns itself when no parent.
*/
@Override
public AbstractBuild<?, ?> getRootBuild() {
return getParentBuild();
AbstractBuild<?, ?> parent = getParentBuild();
return (parent != null) ? parent : this;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/hudson/maven/AbstractMaven3xBuildTest.java
Expand Up @@ -278,6 +278,11 @@ public void testSingleModuleBuild() throws Exception {
for(MavenModule module : expectedNonBuiltModules) {
assertEquals(1,module.getLastBuild().getNumber());
}

// AbstractBuild#getRootBuild() never be null.
assertNotNull(isolated.getRootBuild());
// as there's no parent build, rootBuild is itself.
assertEquals(isolated, isolated.getRootBuild());
}

@Bug(12109)
Expand Down

0 comments on commit aacdd9d

Please sign in to comment.