use of org.jenkinsci.plugins.github_branch_source.GitHubSCMSource in project blueocean-plugin by jenkinsci.
the class GithubScmContentProviderTest method testScmSourceProperties.
private void testScmSourceProperties(String mockedApiUrl) throws Exception {
// ensure the cloud provider works with cloud org folder
String credentialId = createGithubCredential(user);
MultiBranchProject mbp = mockMbp(credentialId, user, GithubScm.DOMAIN_NAME);
// unfortunately overriding the GitHub apiUrl for WireMock returns a "localhost" URL here, so we mock the call
when(((GitHubSCMSource) mbp.getSCMSources().get(0)).getApiUri()).thenReturn(mockedApiUrl);
ScmContentProvider provider = new GithubScmContentProvider();
assertTrue("github provider should support github multi-branch folder", provider.support(mbp));
assertEquals(GithubScm.ID, provider.getScmId());
assertEquals(mockedApiUrl, provider.getApiUrl(mbp));
// ensure the cloud provider doesn't support enterprise org folder
mbp = mockMbp(createGithubEnterpriseCredential(), user, GithubEnterpriseScm.DOMAIN_NAME);
assertFalse("github provider should not support github enterprise org folder", provider.support(mbp));
}
use of org.jenkinsci.plugins.github_branch_source.GitHubSCMSource in project configuration-as-code-plugin by jenkinsci.
the class GlobalLibrariesTest method configure_global_library_using_github.
@Issue("JENKINS-57557")
@Test
@ConfiguredWithCode("GlobalLibrariesGitHubTest.yml")
public void configure_global_library_using_github() {
assertEquals(1, GlobalLibraries.get().getLibraries().size());
final LibraryConfiguration library = GlobalLibraries.get().getLibraries().get(0);
assertEquals("jenkins-pipeline-lib", library.getName());
final SCMSourceRetriever retriever = (SCMSourceRetriever) library.getRetriever();
final GitHubSCMSource scm = (GitHubSCMSource) retriever.getScm();
assertEquals("e43d6600-ba0e-46c5-8eae-3989bf654055", scm.getId());
assertEquals("jenkins-infra", scm.getRepoOwner());
assertEquals("pipeline-library", scm.getRepository());
assertEquals(3, scm.getTraits().size());
final BranchDiscoveryTrait branchDiscovery = (BranchDiscoveryTrait) scm.getTraits().get(0);
assertEquals(1, branchDiscovery.getStrategyId());
final OriginPullRequestDiscoveryTrait prDiscovery = (OriginPullRequestDiscoveryTrait) scm.getTraits().get(1);
assertEquals(2, prDiscovery.getStrategyId());
final ForkPullRequestDiscoveryTrait forkDiscovery = (ForkPullRequestDiscoveryTrait) scm.getTraits().get(2);
assertEquals(3, forkDiscovery.getStrategyId());
assertThat(forkDiscovery.getTrust(), instanceOf(TrustPermission.class));
}
use of org.jenkinsci.plugins.github_branch_source.GitHubSCMSource in project blueocean-plugin by jenkinsci.
the class GithubIssueTest method changeSetEntry.
@Test
public void changeSetEntry() throws Exception {
MultiBranchProject project = mock(MultiBranchProject.class);
Job job = mock(MockJob.class);
Run run = mock(Run.class);
ChangeLogSet logSet = mock(ChangeLogSet.class);
ChangeLogSet.Entry entry = mock(ChangeLogSet.Entry.class);
when(project.getProperties()).thenReturn(new DescribableList(project));
when(entry.getParent()).thenReturn(logSet);
when(logSet.getRun()).thenReturn(run);
when(run.getParent()).thenReturn(job);
when(job.getParent()).thenReturn(project);
GitHubSCMSource source = new GitHubSCMSource("foo", null, null, null, "example", "repo");
when(project.getSCMSources()).thenReturn(Collections.singletonList(source));
when(entry.getMsg()).thenReturn("Closed #123 #124");
Collection<BlueIssue> resolved = BlueIssueFactory.resolve(entry);
Assert.assertEquals(2, resolved.size());
Map<String, BlueIssue> issueMap = resolved.stream().collect(Collectors.toMap(BlueIssue::getId, blueIssue -> blueIssue));
BlueIssue issue123 = issueMap.get("#123");
Assert.assertEquals("https://github.com/example/repo/issues/123", issue123.getURL());
BlueIssue issue124 = issueMap.get("#124");
Assert.assertEquals("https://github.com/example/repo/issues/124", issue124.getURL());
}
Aggregations