GHBranchSubscriber extends AbstractGHBranchSubscriber { static Set<Job> getBranchTriggerJobs(final String repo) { final Set<Job> ret = new HashSet<>(); try (ACLContext ignored = ACL.as(SYSTEM)) { List<Job> jobs = Jenkins.getInstance().getAllItems(Job.class); ret.addAll(FluentIterableWrapper.from(jobs) .filter(isBuildable()) .filter(withBranchTrigger()) .filter(withBranchTriggerRepo(repo)) .toSet() ); } return ret; }    }
@Test public void dontFailOnBadJob() throws IOException, ANTLRException { String goodRepo = "https: final FreeStyleProject job1 = jRule.createProject(FreeStyleProject.class, "bad job"); job1.addProperty(new GithubProjectProperty("http: job1.addTrigger(new GitHubBranchTrigger("", GitHubPRTriggerMode.HEAVY_HOOKS_CRON, emptyList())); Set<Job> jobs = getBranchTriggerJobs(goodRepo); assertThat(jobs, hasSize(0)); final FreeStyleProject job2 = jRule.createProject(FreeStyleProject.class, "good job"); job2.addProperty(new GithubProjectProperty(goodRepo)); job2.addTrigger(new GitHubBranchTrigger("", GitHubPRTriggerMode.HEAVY_HOOKS_CRON, emptyList())); jobs = getBranchTriggerJobs("KostyaSha-auto/test-repo"); assertThat(jobs, hasSize(1)); assertThat(jobs, hasItems(job2)); }