GitHubBranchTrigger extends GitHubTrigger<GitHubBranchTrigger> { @Deprecated public void queueRun(Job<?, ?> job, final String branch) { this.job = job; queueRun(branch); } @Restricted(value = NoExternalUse.class)  GitHubBranchTrigger(); @DataBoundConstructor  GitHubBranchTrigger(String spec, GitHubPRTriggerMode triggerMode, List<GitHubBranchEvent> events); @Override String getFinishMsg(); @DataBoundSetter void setPreStatus(boolean preStatus); boolean isPreStatus(); @Nonnull List<GitHubBranchEvent> getEvents(); @CheckForNull void setEvents(List<GitHubBranchEvent> events); @Override void start(Job item, boolean newInstance); @Override void run(); @Override void doRun(); @Override @CheckForNull GitHubBranchPollingLogAction getPollingLogAction(); @Override DescriptorImpl getDescriptor(); @Deprecated void queueRun(Job<?, ?> job, final String branch); void queueRun(final String branch); synchronized void doRun(String branch); static void updateLocalRepository(@CheckForNull String requestedBranch,
                                             Set<GHBranch> remoteBranches, GitHubBranchRepository localRepository); static final String FINISH_MSG; }
@Test public void asyncTestQueue() throws Exception { Jenkins jenkins = jRule.getInstance(); Thread.sleep(2000); github.service().setGlobalFixedDelay(2_000); FreeStyleProject project = jRule.getInstance().createProject(FreeStyleProject.class, "new-job"); project.addProperty(new GithubProjectProperty("http: project.save(); GitHubBranchTrigger trigger = new GitHubBranchTrigger("", GitHubPRTriggerMode.CRON, Arrays.asList(new GitHubBranchCreatedEvent())); GitHubPluginRepoProvider repoProvider = new GitHubPluginRepoProvider(); repoProvider.setManageHooks(false); repoProvider.setRepoPermission(GHPermission.PULL); trigger.setRepoProvider(repoProvider); project.addTrigger(trigger); project.save(); jRule.configRoundtrip(project); trigger = ghBranchTriggerFromJob(project); jenkins.setNumExecutors(0); for (int i = 1; i < 10; i++) { trigger.queueRun(null); } Awaitility.await() .timeout(120, TimeUnit.SECONDS) .until(() -> { Queue.Item[] items = jenkins.getQueue().getItems(); LOG.info("Jenkins Queue: {}", items.length); return items.length == 2; }); List<Queue.Item> items = jenkins.getQueue().getItems(project); assertThat(items, hasSize(2)); for (Queue.Item item : items) { CauseAction causeAction = item.getAction(CauseAction.class); assertThat(causeAction, notNullValue()); assertThat("Async issues in doRun()", causeAction.getCauses(), not(hasSize(6))); assertThat(causeAction.getCauses(), hasSize(1)); } jenkins.setNumExecutors(2); jRule.waitUntilNoActivity(); assertThat(project.getBuilds(), hasSize(2)); }