diff --git a/src/main/java/com/cloudbees/jenkins/GitHubRepositoryName.java b/src/main/java/com/cloudbees/jenkins/GitHubRepositoryName.java index aca4048ce..0978de5d0 100644 --- a/src/main/java/com/cloudbees/jenkins/GitHubRepositoryName.java +++ b/src/main/java/com/cloudbees/jenkins/GitHubRepositoryName.java @@ -1,6 +1,8 @@ package com.cloudbees.jenkins; import hudson.util.AdaptedIterator; +import org.kohsuke.github.GHOrganization; +import org.kohsuke.github.GHPerson; import org.kohsuke.github.GHRepository; import org.kohsuke.github.GitHub; @@ -58,7 +60,11 @@ public Iterator iterator() { return new AdaptedIterator(GitHubWebHook.get().login(host,userName)) { protected GHRepository adapt(GitHub item) { try { - return item.getUser(userName).getRepository(repositoryName); + GHRepository repo = item.getUser(userName).getRepository(repositoryName); + if (repo == null) { + repo = item.getOrganization(userName).getRepository(repositoryName); + } + return repo; } catch (IOException e) { LOGGER.log(Level.WARNING,"Failed to obtain repository "+this,e); return null;