jenkins.scm.api.trait.SCMTrait Java Examples
The following examples show how to use
jenkins.scm.api.trait.SCMTrait.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GitHubSCMNavigator.java From github-branch-source-plugin with MIT License | 6 votes |
/** * Legacy setter. * * @param buildForkPRHead see * {@link ForkPullRequestDiscoveryTrait#ForkPullRequestDiscoveryTrait(Set, SCMHeadAuthority)}. * @deprecated use {@link ForkPullRequestDiscoveryTrait} */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setBuildForkPRHead(boolean buildForkPRHead) { for (int i = 0; i < traits.size(); i++) { SCMTrait<?> trait = traits.get(i); if (trait instanceof ForkPullRequestDiscoveryTrait) { ForkPullRequestDiscoveryTrait forkTrait = (ForkPullRequestDiscoveryTrait) trait; Set<ChangeRequestCheckoutStrategy> s = forkTrait.getStrategies(); if (buildForkPRHead) { s.add(ChangeRequestCheckoutStrategy.HEAD); } else { s.remove(ChangeRequestCheckoutStrategy.HEAD); } traits.set(i, new ForkPullRequestDiscoveryTrait(s, forkTrait.getTrust())); return; } } if (buildForkPRHead) { traits.add(new ForkPullRequestDiscoveryTrait(EnumSet.of(ChangeRequestCheckoutStrategy.HEAD), new ForkPullRequestDiscoveryTrait.TrustPermission())); } }
Example #2
Source File: GitHubSCMSource.java From github-branch-source-plugin with MIT License | 6 votes |
@Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setBuildForkPRMerge(boolean buildForkPRMerge) { for (int i = 0; i < traits.size(); i++) { SCMTrait<?> trait = traits.get(i); if (trait instanceof ForkPullRequestDiscoveryTrait) { ForkPullRequestDiscoveryTrait forkTrait = (ForkPullRequestDiscoveryTrait) trait; Set<ChangeRequestCheckoutStrategy> s = forkTrait.getStrategies(); if (buildForkPRMerge) { s.add(ChangeRequestCheckoutStrategy.MERGE); } else { s.remove(ChangeRequestCheckoutStrategy.MERGE); } traits.set(i, new ForkPullRequestDiscoveryTrait(s, forkTrait.getTrust())); return; } } if (buildForkPRMerge) { traits.add(new ForkPullRequestDiscoveryTrait(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE), new ForkPullRequestDiscoveryTrait.TrustPermission())); } }
Example #3
Source File: GitHubSCMNavigator.java From github-branch-source-plugin with MIT License | 6 votes |
/** * Legacy setter. * * @param buildOriginPRMerge see {@link OriginPullRequestDiscoveryTrait#OriginPullRequestDiscoveryTrait(Set)}. * @deprecated use {@link OriginPullRequestDiscoveryTrait} */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setBuildOriginPRMerge(boolean buildOriginPRMerge) { for (int i = 0; i < traits.size(); i++) { SCMTrait<?> trait = traits.get(i); if (trait instanceof OriginPullRequestDiscoveryTrait) { Set<ChangeRequestCheckoutStrategy> s = ((OriginPullRequestDiscoveryTrait) trait).getStrategies(); if (buildOriginPRMerge) { s.add(ChangeRequestCheckoutStrategy.MERGE); } else { s.remove(ChangeRequestCheckoutStrategy.MERGE); } traits.set(i, new OriginPullRequestDiscoveryTrait(s)); return; } } if (buildOriginPRMerge) { traits.add(new OriginPullRequestDiscoveryTrait(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE))); } }
Example #4
Source File: GitHubSCMSource.java From github-branch-source-plugin with MIT License | 6 votes |
@Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setBuildOriginPRHead(boolean buildOriginPRHead) { for (int i = 0; i < traits.size(); i++) { SCMTrait<?> trait = traits.get(i); if (trait instanceof OriginPullRequestDiscoveryTrait) { Set<ChangeRequestCheckoutStrategy> s = ((OriginPullRequestDiscoveryTrait) trait).getStrategies(); if (buildOriginPRHead) { s.add(ChangeRequestCheckoutStrategy.HEAD); } else { s.remove(ChangeRequestCheckoutStrategy.HEAD); } traits.set(i, new OriginPullRequestDiscoveryTrait(s)); return; } } if (buildOriginPRHead) { traits.add(new OriginPullRequestDiscoveryTrait(EnumSet.of(ChangeRequestCheckoutStrategy.HEAD))); } }
Example #5
Source File: GitHubSCMSource.java From github-branch-source-plugin with MIT License | 6 votes |
@Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setBuildOriginPRMerge(boolean buildOriginPRMerge) { for (int i = 0; i < traits.size(); i++) { SCMTrait<?> trait = traits.get(i); if (trait instanceof OriginPullRequestDiscoveryTrait) { Set<ChangeRequestCheckoutStrategy> s = ((OriginPullRequestDiscoveryTrait) trait).getStrategies(); if (buildOriginPRMerge) { s.add(ChangeRequestCheckoutStrategy.MERGE); } else { s.remove(ChangeRequestCheckoutStrategy.MERGE); } traits.set(i, new OriginPullRequestDiscoveryTrait(s)); return; } } if (buildOriginPRMerge) { traits.add(new OriginPullRequestDiscoveryTrait(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE))); } }
Example #6
Source File: GitHubSCMNavigator.java From github-branch-source-plugin with MIT License | 6 votes |
/** * Legacy setter. * * @param buildOriginPRHead see {@link OriginPullRequestDiscoveryTrait#OriginPullRequestDiscoveryTrait(Set)}. * @deprecated use {@link OriginPullRequestDiscoveryTrait} */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setBuildOriginPRHead(boolean buildOriginPRHead) { for (int i = 0; i < traits.size(); i++) { SCMTrait<?> trait = traits.get(i); if (trait instanceof OriginPullRequestDiscoveryTrait) { Set<ChangeRequestCheckoutStrategy> s = ((OriginPullRequestDiscoveryTrait) trait).getStrategies(); if (buildOriginPRHead) { s.add(ChangeRequestCheckoutStrategy.HEAD); } else { s.remove(ChangeRequestCheckoutStrategy.HEAD); } traits.set(i, new OriginPullRequestDiscoveryTrait(s)); return; } } if (buildOriginPRHead) { traits.add(new OriginPullRequestDiscoveryTrait(EnumSet.of(ChangeRequestCheckoutStrategy.HEAD))); } }
Example #7
Source File: GitHubSCMSource.java From github-branch-source-plugin with MIT License | 6 votes |
@Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setBuildOriginBranchWithPR(boolean buildOriginBranchWithPR) { for (int i = 0; i < traits.size(); i++) { SCMTrait<?> trait = traits.get(i); if (trait instanceof BranchDiscoveryTrait) { BranchDiscoveryTrait previous = (BranchDiscoveryTrait) trait; if (buildOriginBranchWithPR || previous.isBuildBranch()) { traits.set(i, new BranchDiscoveryTrait(previous.isBuildBranch(), buildOriginBranchWithPR)); } else { traits.remove(i); } return; } } if (buildOriginBranchWithPR) { traits.add(new BranchDiscoveryTrait(false, buildOriginBranchWithPR)); } }
Example #8
Source File: GitHubSCMSource.java From github-branch-source-plugin with MIT License | 6 votes |
@Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setBuildForkPRHead(boolean buildForkPRHead) { for (int i = 0; i < traits.size(); i++) { SCMTrait<?> trait = traits.get(i); if (trait instanceof ForkPullRequestDiscoveryTrait) { ForkPullRequestDiscoveryTrait forkTrait = (ForkPullRequestDiscoveryTrait) trait; Set<ChangeRequestCheckoutStrategy> s = forkTrait.getStrategies(); if (buildForkPRHead) { s.add(ChangeRequestCheckoutStrategy.HEAD); } else { s.remove(ChangeRequestCheckoutStrategy.HEAD); } traits.set(i, new ForkPullRequestDiscoveryTrait(s, forkTrait.getTrust())); return; } } if (buildForkPRHead) { traits.add(new ForkPullRequestDiscoveryTrait(EnumSet.of(ChangeRequestCheckoutStrategy.HEAD), new ForkPullRequestDiscoveryTrait.TrustPermission())); } }
Example #9
Source File: GitHubSCMSource.java From github-branch-source-plugin with MIT License | 6 votes |
@Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setBuildOriginBranch(boolean buildOriginBranch) { for (int i = 0; i < traits.size(); i++) { SCMTrait<?> trait = traits.get(i); if (trait instanceof BranchDiscoveryTrait) { BranchDiscoveryTrait previous = (BranchDiscoveryTrait) trait; if (buildOriginBranch || previous.isBuildBranchesWithPR()) { traits.set(i, new BranchDiscoveryTrait(buildOriginBranch, previous.isBuildBranchesWithPR())); } else { traits.remove(i); } return; } } if (buildOriginBranch) { traits.add(new BranchDiscoveryTrait(buildOriginBranch, false)); } }
Example #10
Source File: GitHubSCMNavigator.java From github-branch-source-plugin with MIT License | 6 votes |
/** * Legacy setter. * * @param buildForkPRMerge see {@link ForkPullRequestDiscoveryTrait#ForkPullRequestDiscoveryTrait(Set, SCMHeadAuthority)}. * @deprecated use {@link ForkPullRequestDiscoveryTrait} */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setBuildForkPRMerge(boolean buildForkPRMerge) { for (int i = 0; i < traits.size(); i++) { SCMTrait<?> trait = traits.get(i); if (trait instanceof ForkPullRequestDiscoveryTrait) { ForkPullRequestDiscoveryTrait forkTrait = (ForkPullRequestDiscoveryTrait) trait; Set<ChangeRequestCheckoutStrategy> s = forkTrait.getStrategies(); if (buildForkPRMerge) { s.add(ChangeRequestCheckoutStrategy.MERGE); } else { s.remove(ChangeRequestCheckoutStrategy.MERGE); } traits.set(i, new ForkPullRequestDiscoveryTrait(s, forkTrait.getTrust())); return; } } if (buildForkPRMerge) { traits.add(new ForkPullRequestDiscoveryTrait(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE), new ForkPullRequestDiscoveryTrait.TrustPermission())); } }
Example #11
Source File: GitHubSCMNavigator.java From github-branch-source-plugin with MIT License | 6 votes |
/** * Legacy setter. * * @param buildOriginBranchWithPR see {@link BranchDiscoveryTrait#BranchDiscoveryTrait(boolean, boolean)}. * @deprecated use {@link BranchDiscoveryTrait} */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setBuildOriginBranchWithPR(boolean buildOriginBranchWithPR) { for (int i = 0; i < traits.size(); i++) { SCMTrait<?> trait = traits.get(i); if (trait instanceof BranchDiscoveryTrait) { BranchDiscoveryTrait previous = (BranchDiscoveryTrait) trait; if (buildOriginBranchWithPR || previous.isBuildBranch()) { traits.set(i, new BranchDiscoveryTrait(previous.isBuildBranch(), buildOriginBranchWithPR)); } else { traits.remove(i); } return; } } if (buildOriginBranchWithPR) { traits.add(new BranchDiscoveryTrait(false, buildOriginBranchWithPR)); } }
Example #12
Source File: GitPipelineCreateRequestTest.java From blueocean-plugin with MIT License | 6 votes |
@Test public void createPipeline() throws UnirestException, IOException { User user = login("vivek", "Vivek Pandey", "[email protected]"); Map r = new PipelineBaseTest.RequestBuilder(baseUrl) .status(201) .jwtToken(getJwtToken(j.jenkins, user.getId(), user.getId())) .crumb( crumb ) .post("/organizations/jenkins/pipelines/") .data(ImmutableMap.of("name", "pipeline1", "$class", "io.jenkins.blueocean.blueocean_git_pipeline.GitPipelineCreateRequest", "scmConfig", ImmutableMap.of("id", GitScm.ID, "uri", sampleRepo.toString()))) .build(Map.class); assertNotNull(r); assertEquals("pipeline1", r.get("name")); MultiBranchProject mbp = (MultiBranchProject) j.getInstance().getItem("pipeline1"); GitSCMSource source = (GitSCMSource) mbp.getSCMSources().get(0); List<SCMSourceTrait> traits = source.getTraits(); Assert.assertNotNull(SCMTrait.find(traits, BranchDiscoveryTrait.class)); Assert.assertNotNull(SCMTrait.find(traits, CleanAfterCheckoutTrait.class)); Assert.assertNotNull(SCMTrait.find(traits, CleanBeforeCheckoutTrait.class)); Assert.assertNotNull(SCMTrait.find(traits, LocalBranchTrait.class)); }
Example #13
Source File: GitHubSCMNavigator.java From github-branch-source-plugin with MIT License | 6 votes |
/** * Legacy getter. * * @return {@link SSHCheckoutTrait#getCredentialsId()} with some mangling to preserve legacy behaviour. * @deprecated use {@link SSHCheckoutTrait} */ @CheckForNull @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") public String getCheckoutCredentialsId() { for (SCMTrait<?> trait : traits) { if (trait instanceof SSHCheckoutTrait) { return StringUtils.defaultString( ((SSHCheckoutTrait) trait).getCredentialsId(), GitHubSCMSource.DescriptorImpl.ANONYMOUS ); } } return DescriptorImpl.SAME; }
Example #14
Source File: GitHubSCMNavigator.java From github-branch-source-plugin with MIT License | 6 votes |
/** * Legacy setter. * * @param pattern see {@link RegexSCMSourceFilterTrait#RegexSCMSourceFilterTrait(String)}. * @deprecated use {@link RegexSCMSourceFilterTrait} */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setPattern(String pattern) { for (int i = 0; i < traits.size(); i++) { SCMTrait<?> trait = traits.get(i); if (trait instanceof RegexSCMSourceFilterTrait) { if (".*".equals(pattern)) { traits.remove(i); } else { traits.set(i, new RegexSCMSourceFilterTrait(pattern)); } return; } } if (!".*".equals(pattern)) { traits.add(new RegexSCMSourceFilterTrait(pattern)); } }
Example #15
Source File: GitHubSCMNavigator.java From github-branch-source-plugin with MIT License | 6 votes |
/** * Legacy setter. * * @param buildOriginBranch see {@link BranchDiscoveryTrait#BranchDiscoveryTrait(boolean, boolean)}. * @deprecated use {@link BranchDiscoveryTrait} */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setBuildOriginBranch(boolean buildOriginBranch) { for (int i = 0; i < traits.size(); i++) { SCMTrait<?> trait = traits.get(i); if (trait instanceof BranchDiscoveryTrait) { BranchDiscoveryTrait previous = (BranchDiscoveryTrait) trait; if (buildOriginBranch || previous.isBuildBranchesWithPR()) { traits.set(i, new BranchDiscoveryTrait(buildOriginBranch, previous.isBuildBranchesWithPR())); } else { traits.remove(i); } return; } } if (buildOriginBranch) { traits.add(new BranchDiscoveryTrait(buildOriginBranch, false)); } }
Example #16
Source File: GitHubSCMNavigator.java From github-branch-source-plugin with MIT License | 6 votes |
/** * Legacy setter. * * @param excludes see {@link WildcardSCMHeadFilterTrait#WildcardSCMHeadFilterTrait(String, String)} * @deprecated use {@link WildcardSCMHeadFilterTrait}. */ @Deprecated @Restricted(NoExternalUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setExcludes(@NonNull String excludes) { for (int i = 0; i < traits.size(); i++) { SCMTrait<?> trait = traits.get(i); if (trait instanceof WildcardSCMHeadFilterTrait) { WildcardSCMHeadFilterTrait existing = (WildcardSCMHeadFilterTrait) trait; if ("*".equals(existing.getIncludes()) && "".equals(excludes)) { traits.remove(i); } else { traits.set(i, new WildcardSCMHeadFilterTrait(existing.getIncludes(), excludes)); } return; } } if (!"".equals(excludes)) { traits.add(new WildcardSCMHeadFilterTrait("*", excludes)); } }
Example #17
Source File: GitHubSCMNavigatorTraitsTest.java From github-branch-source-plugin with MIT License | 6 votes |
@Test public void given__legacyCode_withoutExcludes__when__setIncludes_value__then__traitUpdated() { GitHubSCMNavigator instance = new GitHubSCMNavigator("test"); instance.setTraits(new SCMTrait[]{ new BranchDiscoveryTrait(true, false), new RegexSCMSourceFilterTrait("job.*"), new WildcardSCMHeadFilterTrait("feature/*", "") }); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("")); assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("")) ))); instance.setIncludes("bug/*"); assertThat(instance.getIncludes(), is("bug/*")); assertThat(instance.getExcludes(), is("")); assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("bug/*")), hasProperty("excludes", is("")) ))); }
Example #18
Source File: GitHubSCMNavigatorTraitsTest.java From github-branch-source-plugin with MIT License | 6 votes |
@Test public void given__legacyCode_withExcludes__when__setIncludes_value__then__traitUpdated() { GitHubSCMNavigator instance = new GitHubSCMNavigator("test"); instance.setTraits(new SCMTrait[]{ new BranchDiscoveryTrait(true, false), new RegexSCMSourceFilterTrait("job.*"), new WildcardSCMHeadFilterTrait("feature/*", "feature/ignore") }); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("feature/ignore")); assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("feature/ignore")) ))); instance.setIncludes("bug/*"); assertThat(instance.getIncludes(), is("bug/*")); assertThat(instance.getExcludes(), is("feature/ignore")); assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("bug/*")), hasProperty("excludes", is("feature/ignore")) ))); }
Example #19
Source File: GitHubSCMNavigator.java From github-branch-source-plugin with MIT License | 6 votes |
/** * Legacy setter. * * @param includes see {@link WildcardSCMHeadFilterTrait#WildcardSCMHeadFilterTrait(String, String)} * @deprecated use {@link WildcardSCMHeadFilterTrait}. */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setIncludes(@NonNull String includes) { for (int i = 0; i < traits.size(); i++) { SCMTrait<?> trait = traits.get(i); if (trait instanceof WildcardSCMHeadFilterTrait) { WildcardSCMHeadFilterTrait existing = (WildcardSCMHeadFilterTrait) trait; if ("*".equals(includes) && "".equals(existing.getExcludes())) { traits.remove(i); } else { traits.set(i, new WildcardSCMHeadFilterTrait(includes, existing.getExcludes())); } return; } } if (!"*".equals(includes)) { traits.add(new WildcardSCMHeadFilterTrait(includes, "")); } }
Example #20
Source File: GitHubSCMNavigator.java From github-branch-source-plugin with MIT License | 5 votes |
/** * Legacy getter. * * @return {@link ForkPullRequestDiscoveryTrait#getStrategies()}. * @deprecated use {@link ForkPullRequestDiscoveryTrait#getStrategies()} */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") public boolean getBuildForkPRMerge() { for (SCMTrait<?> trait : traits) { if (trait instanceof ForkPullRequestDiscoveryTrait) { return ((ForkPullRequestDiscoveryTrait) trait).getStrategies() .contains(ChangeRequestCheckoutStrategy.MERGE); } } return false; }
Example #21
Source File: GitHubSCMNavigator.java From github-branch-source-plugin with MIT License | 5 votes |
/** * Legacy getter. * * @return {@link BranchDiscoveryTrait#isBuildBranchesWithPR()}. * @deprecated use {@link BranchDiscoveryTrait} */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") public boolean getBuildOriginBranchWithPR() { for (SCMTrait<?> trait : traits) { if (trait instanceof BranchDiscoveryTrait) { return ((BranchDiscoveryTrait) trait).isBuildBranchesWithPR(); } } return false; }
Example #22
Source File: GitHubSCMNavigator.java From github-branch-source-plugin with MIT License | 5 votes |
/** * Legacy getter. * @return {@link BranchDiscoveryTrait#isBuildBranch()}. * @deprecated use {@link BranchDiscoveryTrait} */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") public boolean getBuildOriginBranch() { for (SCMTrait<?> trait : traits) { if (trait instanceof BranchDiscoveryTrait) { return ((BranchDiscoveryTrait) trait).isBuildBranch(); } } return false; }
Example #23
Source File: GitHubSCMNavigator.java From github-branch-source-plugin with MIT License | 5 votes |
/** * Legacy getter. * * @return {@link OriginPullRequestDiscoveryTrait#getStrategies()}. * @deprecated use {@link OriginPullRequestDiscoveryTrait#getStrategies()} */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") public boolean getBuildOriginPRMerge() { for (SCMTrait<?> trait : traits) { if (trait instanceof OriginPullRequestDiscoveryTrait) { return ((OriginPullRequestDiscoveryTrait) trait).getStrategies() .contains(ChangeRequestCheckoutStrategy.MERGE); } } return false; }
Example #24
Source File: GitHubSCMNavigator.java From github-branch-source-plugin with MIT License | 5 votes |
/** * Legacy getter. * * @return {@link OriginPullRequestDiscoveryTrait#getStrategies()}. * @deprecated use {@link OriginPullRequestDiscoveryTrait#getStrategies()} */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") public boolean getBuildOriginPRHead() { for (SCMTrait<?> trait : traits) { if (trait instanceof OriginPullRequestDiscoveryTrait) { return ((OriginPullRequestDiscoveryTrait) trait).getStrategies() .contains(ChangeRequestCheckoutStrategy.HEAD); } } return false; }
Example #25
Source File: GitHubSCMNavigatorTest.java From github-branch-source-plugin with MIT License | 5 votes |
@Test public void fetchReposFromTeamSlug() throws Exception { final Set<String> projectNames = new HashSet<>(); final SCMSourceObserver observer = getObserver(projectNames); List<SCMTrait<? extends SCMTrait<?>>> traits = new ArrayList<>(navigator.getTraits()); traits.add(new TeamSlugTrait("justice-league")); navigator.setTraits(traits); navigator.visitSources(SCMSourceObserver.filter(observer, "Hello-World", "github-branch-source-plugin")); assertThat(projectNames, containsInAnyOrder("Hello-World", "github-branch-source-plugin")); }
Example #26
Source File: GitHubSCMNavigator.java From github-branch-source-plugin with MIT License | 5 votes |
/** * Legacy getter. * * @return {@link ForkPullRequestDiscoveryTrait#getStrategies()}. * @deprecated use {@link ForkPullRequestDiscoveryTrait#getStrategies()} */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") public boolean getBuildForkPRHead() { for (SCMTrait<?> trait : traits) { if (trait instanceof ForkPullRequestDiscoveryTrait) { return ((ForkPullRequestDiscoveryTrait) trait).getStrategies() .contains(ChangeRequestCheckoutStrategy.HEAD); } } return false; }
Example #27
Source File: GitHubSCMNavigator.java From github-branch-source-plugin with MIT License | 5 votes |
/** * Legacy getter. * * @return {@link RegexSCMSourceFilterTrait#getRegex()}. * @deprecated use {@link RegexSCMSourceFilterTrait} */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.2.0") public String getPattern() { for (SCMTrait<?> trait : traits) { if (trait instanceof RegexSCMSourceFilterTrait) { return ((RegexSCMSourceFilterTrait) trait).getRegex(); } } return ".*"; }
Example #28
Source File: GitHubSCMNavigatorTraitsTest.java From github-branch-source-plugin with MIT License | 5 votes |
@Test public void modern() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.id(), is("https://api.github.com::cloudbeers")); assertThat(instance.getRepoOwner(), is("cloudbeers")); assertThat(instance.getApiUri(), is(nullValue())); assertThat(instance.getCredentialsId(), is("bcaef157-f105-407f-b150-df7722eab6c1")); assertThat(instance.getTraits(), is(Collections.<SCMTrait<?>>emptyList())); }
Example #29
Source File: GitHubSCMNavigatorTraitsTest.java From github-branch-source-plugin with MIT License | 5 votes |
@Test public void basic_cloud() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.id(), is("https://api.github.com::cloudbeers")); assertThat(instance.getRepoOwner(), is("cloudbeers")); assertThat(instance.getApiUri(), is(nullValue())); assertThat(instance.getCredentialsId(), is("bcaef157-f105-407f-b150-df7722eab6c1")); assertThat("SAME checkout credentials should mean no checkout trait", instance.getTraits(), not(hasItem(Matchers.<SCMTrait<?>>instanceOf(SSHCheckoutTrait.class)))); assertThat(".* as a pattern should mean no RegexSCMSourceFilterTrait", instance.getTraits(), not(hasItem(Matchers.<SCMTrait<?>>instanceOf(RegexSCMSourceFilterTrait.class)))); assertThat(instance.getTraits(), containsInAnyOrder( Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)), hasProperty("trust", instanceOf(ForkPullRequestDiscoveryTrait.TrustPermission.class)) ) ) ); // legacy API assertThat(instance.getCheckoutCredentialsId(), is("SAME")); assertThat(instance.getPattern(), is(".*")); assertThat(instance.getIncludes(), is("*")); assertThat(instance.getExcludes(), is("")); }
Example #30
Source File: GitHubSCMNavigatorTraitsTest.java From github-branch-source-plugin with MIT License | 5 votes |
@Test public void given__legacyCode__when__setPattern_custom__then__patternSetAndTraitUpdated() { GitHubSCMNavigator instance = new GitHubSCMNavigator("test"); instance.setTraits(new SCMTrait[]{new BranchDiscoveryTrait(true, false), new RegexSCMSourceFilterTrait("job.*"), new SSHCheckoutTrait("dummy")}); assertThat(instance.getPattern(), is("job.*")); assertThat(instance.getTraits(), Matchers.hasItem(instanceOf(RegexSCMSourceFilterTrait.class))); instance.setPattern("project.*"); assertThat(instance.getPattern(), is("project.*")); assertThat(instance.getTraits(), not(Matchers.hasItem( allOf(instanceOf(RegexSCMSourceFilterTrait.class), hasProperty("regex", is("job.*")))))); assertThat(instance.getTraits(), Matchers.hasItem( allOf(instanceOf(RegexSCMSourceFilterTrait.class), hasProperty("regex", is("project.*"))))); }