Skip to content

Commit

Permalink
[FIXED JENKINS-34239] Need to rerun doAddSpecificDescriptors in case …
Browse files Browse the repository at this point in the history
…a MultiBranchProjectFactoryDescriptor is added first, then a SCMNavigatorDescriptor.
  • Loading branch information
jglick authored and svanoort committed Sep 3, 2016
1 parent 0d50f62 commit d297b94
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pom.xml
Expand Up @@ -29,7 +29,8 @@
<parent> <parent>
<groupId>org.jenkins-ci.plugins</groupId> <groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId> <artifactId>plugin</artifactId>
<version>2.7</version> <version>2.14</version>
<relativePath/>
</parent> </parent>


<artifactId>branch-api</artifactId> <artifactId>branch-api</artifactId>
Expand All @@ -44,7 +45,7 @@
<licenses> <licenses>
<license> <license>
<name>The MIT license</name> <name>The MIT license</name>
<url>http://www.opensource.org/licenses/mit-license.php</url> <url>https://opensource.org/licenses/MIT</url>
<distribution>repo</distribution> <distribution>repo</distribution>
</license> </license>
</licenses> </licenses>
Expand All @@ -60,7 +61,7 @@
<connection>scm:git:git://github.com/jenkinsci/branch-api-plugin.git</connection> <connection>scm:git:git://github.com/jenkinsci/branch-api-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/branch-api-plugin.git</developerConnection> <developerConnection>scm:git:git@github.com:jenkinsci/branch-api-plugin.git</developerConnection>
<url>http://github.com/jenkinsci/branch-api-plugin</url> <url>http://github.com/jenkinsci/branch-api-plugin</url>
<tag>branch-api-1.10</tag> <tag>branch-api-1.10.1</tag>
</scm> </scm>


<properties> <properties>
Expand All @@ -70,14 +71,14 @@
<repositories> <repositories>
<repository> <repository>
<id>repo.jenkins-ci.org</id> <id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url> <url>https://repo.jenkins-ci.org/public/</url>
</repository> </repository>
</repositories> </repositories>


<pluginRepositories> <pluginRepositories>
<pluginRepository> <pluginRepository>
<id>repo.jenkins-ci.org</id> <id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url> <url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository> </pluginRepository>
</pluginRepositories> </pluginRepositories>


Expand Down
Expand Up @@ -122,6 +122,7 @@ public static void addSpecificDescriptors() {
LOGGER.fine("ran addSpecificDescriptors"); LOGGER.fine("ran addSpecificDescriptors");
doAddSpecificDescriptors(); doAddSpecificDescriptors();
ExtensionList.lookup(MultiBranchProjectFactoryDescriptor.class).addListener(new ListenerImpl()); ExtensionList.lookup(MultiBranchProjectFactoryDescriptor.class).addListener(new ListenerImpl());
ExtensionList.lookup(SCMNavigatorDescriptor.class).addListener(new ListenerImpl());
} }


private static class ListenerImpl extends ExtensionListListener { private static class ListenerImpl extends ExtensionListListener {
Expand Down
Expand Up @@ -34,6 +34,7 @@
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import jenkins.scm.api.SCMNavigator; import jenkins.scm.api.SCMNavigator;
import jenkins.scm.api.SCMNavigatorDescriptor; import jenkins.scm.api.SCMNavigatorDescriptor;
import jenkins.scm.api.SCMSourceObserver; import jenkins.scm.api.SCMSourceObserver;
Expand All @@ -43,12 +44,15 @@
import org.junit.Test; import org.junit.Test;
import org.jvnet.hudson.test.Issue; import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule; import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.LoggerRule;
import org.jvnet.hudson.test.TestExtension; import org.jvnet.hudson.test.TestExtension;


public class CustomOrganizationFolderDescriptorTest { public class CustomOrganizationFolderDescriptorTest {


@Rule @Rule
public JenkinsRule r = new JenkinsRule(); public JenkinsRule r = new JenkinsRule();
@Rule
public LoggerRule logger = new LoggerRule().record(CustomOrganizationFolderDescriptor.class, Level.ALL);


@Test @Test
public void noNavigatorNoFactoryInstalled() throws Exception { public void noNavigatorNoFactoryInstalled() throws Exception {
Expand Down Expand Up @@ -98,6 +102,16 @@ public void dynamicLoad() throws Exception {
assertEquals(Collections.singletonList("MockNavigator"), newItemTypes()); assertEquals(Collections.singletonList("MockNavigator"), newItemTypes());
} }


@Issue("JENKINS-34239")
@SuppressWarnings("deprecation") // ExtensionList.add simulating dynamic installation
@Test
public void dynamicLoadReversed() throws Exception {
assertEquals(Collections.emptyList(), newItemTypes());
ExtensionList.lookup(MultiBranchProjectFactoryDescriptor.class).add(new SomeNavigatorSomeFactoryInstalledDescriptor2());
ExtensionList.lookup(SCMNavigatorDescriptor.class).add(new SomeNavigatorSomeFactoryInstalledDescriptor1());
assertEquals(Collections.singletonList("MockNavigator"), newItemTypes());
}

@Issue("JENKINS-31949") @Issue("JENKINS-31949")
@Test @Test
public void insideFolder() throws Exception { public void insideFolder() throws Exception {
Expand Down

0 comments on commit d297b94

Please sign in to comment.