Skip to content
Browse files

[JENKINS-48035] Add a GitHubRepositoryNameContributor that recognises…

… multi branch

The existing name contributors could only find the repo name if a build
of a branch had been made and added git build data to the job.
Since branches are discovered and built after GitHubSCMSource.afterSaved is called
there was no repo names recognised to add webhooks to.

This only solves the case when a single multi branch project is created.
Because when an org folder creates the multi branch jobs it does not call
afterSaved on the children. So that needs to be fixed someplace else.
  • Loading branch information
rsandell committed Dec 11, 2017
1 parent aa3e8bd commit 9213e3b0d1b12493e5d319fb4f3cb0f7be05edac
13 pom.xml
@@ -23,7 +23,7 @@

@@ -68,6 +68,11 @@
<!-- Currently just here for interactive testing via hpi:run: -->
@@ -88,12 +93,6 @@
@@ -0,0 +1,30 @@
package org.jenkinsci.plugins.github_branch_source;

import com.cloudbees.jenkins.GitHubRepositoryName;
import com.cloudbees.jenkins.GitHubRepositoryNameContributor;
import hudson.Extension;
import hudson.model.Item;
import jenkins.branch.MultiBranchProject;

import java.util.Collection;

public class GitHubSCMSourceRepositoryNameContributor extends GitHubRepositoryNameContributor {

public void parseAssociatedNames(Item item, Collection<GitHubRepositoryName> result) {
if (item instanceof MultiBranchProject) {
MultiBranchProject mp = (MultiBranchProject) item;
for (Object o : mp.getSCMSources()) {
if (o instanceof GitHubSCMSource) {
GitHubSCMSource gitHubSCMSource = (GitHubSCMSource) o;
result.add(new GitHubRepositoryName(


0 comments on commit 9213e3b

Please sign in to comment.
You can’t perform that action at this time.