hudson.plugins.git.BranchSpec Java Examples
The following examples show how to use
hudson.plugins.git.BranchSpec.
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: ScmJobEventTriggerMatcher.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 6 votes |
private boolean matchBranch(final Event event, final List<BranchSpec> branchSpecs) {//TODO use it for (BranchSpec branchSpec : branchSpecs) { log.debug("branchSpec= %s", branchSpec.toString()); if (branchSpec.matches(event.getBranch())) { log.info("Event branch: %s matched branch: %s", event.getBranch(), branchSpec.getName()); return true; } else if (branchSpec.matches(event.getNoPrefixBranch())) { log.info("Event no-prefix-branch: %s matched branch: %s", event.getNoPrefixBranch(), branchSpec.getName()); return true; } } log.info("Found no event matched any branch", event.getArn()); return false; }
Example #2
Source File: DeflakeGitBuildChooserTest.java From flaky-test-handler-plugin with Apache License 2.0 | 6 votes |
@Test public void testDeflakeCheckoutFailingRevision() throws Exception { FreeStyleProject project = setupProject(Arrays.asList( new BranchSpec("master") )); DeflakeCause deflakeCause = initRepoWithDeflakeBuild(project); // Checkout without deflake cause will see the newly committed file build(project, Result.SUCCESS, commitFile2); // Checkout with deflake cause will only see the first file AbstractBuild deflakeBuild = project.scheduleBuild2(0, deflakeCause, new FailingTestResultAction()).get(); assertTrue("could not see the old committed file", deflakeBuild.getWorkspace().child(commitFile1).exists()); assertFalse("should not see the newly committed file", deflakeBuild.getWorkspace().child(commitFile2).exists()); }
Example #3
Source File: PushHookTriggerHandlerGitlabServerTest.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
@Theory public void createRevisionParameterAction_pushCommitRequestWith2Remotes(GitLabPushRequestSamples samples) throws Exception { PushHook hook = samples.pushCommitRequest(); GitSCM gitSCM = new GitSCM(Arrays.asList(new UserRemoteConfig("[email protected]:test.git", null, null, null), new UserRemoteConfig("[email protected]:fork.git", "fork", null, null)), Collections.singletonList(new BranchSpec("")), false, Collections.<SubmoduleConfig>emptyList(), null, null, null); RevisionParameterAction revisionParameterAction = new PushHookTriggerHandlerImpl(false).createRevisionParameter(hook, gitSCM); assertThat(revisionParameterAction, is(notNullValue())); assertThat(revisionParameterAction.commit, is(hook.getAfter())); assertFalse(revisionParameterAction.canOriginateFrom(new ArrayList<RemoteConfig>())); }
Example #4
Source File: RepoInfo.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 5 votes |
public static RepoInfo fromSqsJob(SQSJob sqsJob) { if (sqsJob == null) { return null; } RepoInfo repoInfo = new RepoInfo(); List<SCM> scms = sqsJob.getScmList(); List<String> codeCommitUrls = new ArrayList<>(); List<String> nonCodeCommitUrls = new ArrayList<>(); List<String> branches = new ArrayList<>(); for (SCM scm : scms) { if (scm instanceof GitSCM) {//TODO refactor to visitor GitSCM git = (GitSCM) scm; List<RemoteConfig> repos = git.getRepositories(); for (RemoteConfig repo : repos) { for (URIish urIish : repo.getURIs()) { String url = urIish.toString(); if (StringUtils.isCodeCommitRepo(url)) { codeCommitUrls.add(url); } else { nonCodeCommitUrls.add(url); } } } for (BranchSpec branchSpec : git.getBranches()) { branches.add(branchSpec.getName()); } } } repoInfo.nonCodeCommitUrls = nonCodeCommitUrls; repoInfo.codeCommitUrls = codeCommitUrls; repoInfo.branches = branches; return repoInfo; }
Example #5
Source File: SQSScmConfig.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 5 votes |
public List<BranchSpec> getBranchSpecs() { if (CollectionUtils.isEmpty(branchSpecs)) { branchSpecs = new ArrayList<>(); List<String> branches = com.ribose.jenkins.plugin.awscodecommittrigger.utils.StringUtils.parseCsvString(subscribedBranches); for (String branch : branches) { branchSpecs.add(new BranchSpec(branch)); } } return branchSpecs; }
Example #6
Source File: ScmFactoryImpl.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 5 votes |
public GitSCM createGit(String url, List<BranchSpec> branchSpecs) { return new GitSCM( GitSCM.createRepoList(url, null), branchSpecs, false, Collections.<SubmoduleConfig>emptyList(), null, null, Collections.<GitSCMExtension>emptyList() ); }
Example #7
Source File: StringUtilsTest.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 5 votes |
@Test public void testGitBranchSpec() { BranchSpec gitBranchSpec = new BranchSpec("master"); String fetchBranch = "refs/heads/master"; boolean matched = gitBranchSpec.matches(fetchBranch); Assertions.assertThat(matched).isTrue(); }
Example #8
Source File: MockGitSCM.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 5 votes |
@DataBoundConstructor public MockGitSCM( List<UserRemoteConfig> userRemoteConfigs, List<BranchSpec> branches, Boolean doGenerateSubmoduleConfigurations, Collection<SubmoduleConfig> submoduleCfg, GitRepositoryBrowser browser, String gitTool, List<GitSCMExtension> extensions ) { super(userRemoteConfigs, branches, doGenerateSubmoduleConfigurations, submoduleCfg, browser, gitTool, extensions); this.url = userRemoteConfigs.get(0).getUrl(); }
Example #9
Source File: MockGitSCM.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 5 votes |
public static MockGitSCM fromUrlAndBranchSpecs(String url, List<BranchSpec> branchSpecs) { return new MockGitSCM( GitSCM.createRepoList(url, null), branchSpecs, false, Collections.<SubmoduleConfig>emptyList(), null, null, Collections.<GitSCMExtension>emptyList() ); }
Example #10
Source File: MockGitSCM.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 5 votes |
public static MockGitSCM fromSqsMessage(String sqsMessage, String branches) { String url = StringUtils.findByUniqueJsonKey(sqsMessage, "__gitUrl__"); List<BranchSpec> branchSpecs = new ArrayList<>(); for (String branch : branches.split(",")) { branchSpecs.add(new BranchSpec(branch)); } return fromUrlAndBranchSpecs(url, branchSpecs); }
Example #11
Source File: ScmConfigIT.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 5 votes |
@Parameterized.Parameters(name = "{0}") public static List<Object[]> fixtures() { return Arrays.asList(new Object[][]{ { "internal scm matched", new ProjectFixture() .setSendBranches("refs/heads/bar") .setScm(MockGitSCM.fromUrlAndBranchSpecs(defaultSCMUrl, Collections.singletonList(new BranchSpec("refs/heads/bar")))) .setSubscribeInternalScm(true) .setShouldStarted(true) }, { "internal scm not matched", new ProjectFixture() .setSendBranches("refs/heads/foo") .setScm(MockGitSCM.fromUrlAndBranchSpecs(defaultSCMUrl, Collections.singletonList(new BranchSpec("refs/heads/bar")))) .setSubscribeInternalScm(true) .setShouldStarted(false) }, { "external scm not matched", new ProjectFixture() .setSendBranches("refs/heads/bar") .setScm(MockGitSCM.fromUrlAndBranchSpecs(defaultSCMUrl, Collections.singletonList(new BranchSpec("refs/heads/bar")))) .setScmConfigs(scmConfigFactory.createERs("", "")) .setSubscribeInternalScm(false) .setShouldStarted(false) }, { "external scm matched", new ProjectFixture() .setSendBranches("refs/heads/bar") .setScm(MockGitSCM.fromUrlAndBranchSpecs(defaultSCMUrl, Collections.singletonList(new BranchSpec("refs/heads/bar")))) .setScmConfigs(scmConfigFactory.createERs(defaultSCMUrl, "refs/heads/bar")) .setSubscribeInternalScm(false) .setShouldStarted(true) }, }); }
Example #12
Source File: ScmInternalSubscriptionIT.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 5 votes |
@Parameterized.Parameters(name = "{0}") public static List<Object[]> fixtures() { return Arrays.asList(new Object[][]{ { "branch matched", new ProjectFixture() .setSendBranches("refs/heads/foo") .setScm(MockGitSCM.fromUrlAndBranchSpecs(defaultSCMUrl, Collections.singletonList(new BranchSpec("refs/heads/foo")))) .setShouldStarted(true) }, { "no branch not match", new ProjectFixture() .setSendBranches("refs/heads/bar") .setScm(MockGitSCM.fromUrlAndBranchSpecs(defaultSCMUrl, Collections.singletonList(new BranchSpec("refs/heads/foo")))) .setShouldStarted(false) }, { "scm is undefined", new ProjectFixture() .setSendBranches("refs/heads/bar") .setScm(new NullSCM()) .setShouldStarted(false) }, { "branch is undefined", new ProjectFixture() .setSendBranches("refs/heads/bar") .setScm(MockGitSCM.fromUrlAndBranchSpecs(defaultSCMUrl, Collections.<BranchSpec>emptyList())) .setShouldStarted(false) } }); }
Example #13
Source File: ScmExternalSubscriptionIT.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 5 votes |
@Parameterized.Parameters(name = "{0}") public static List<Object[]> fixtures() { String gitUrl = defaultSCMUrl + "_diff"; return Arrays.asList(new Object[][]{ { "git url & branch matched", new ProjectFixture() .setSendBranches("refs/heads/foo") .setScm(MockGitSCM.fromUrlAndBranchSpecs(defaultSCMUrl, Collections.singletonList(new BranchSpec("refs/heads/foo")))) .setScmConfigs(scmConfigFactory.createERs(defaultSCMUrl, "refs/heads/foo")) .setShouldStarted(true) }, { "git url match but branch not matched", new ProjectFixture() .setSendBranches("refs/heads/foo") .setScm(MockGitSCM.fromUrlAndBranchSpecs(defaultSCMUrl, Collections.singletonList(new BranchSpec("refs/heads/foo")))) .setScmConfigs(scmConfigFactory.createERs(defaultSCMUrl, "refs/heads/bar")) .setShouldStarted(false) }, { "git url not match but branch matched", new ProjectFixture() .setSendBranches("refs/heads/foo") .setScm(MockGitSCM.fromUrlAndBranchSpecs(defaultSCMUrl, Collections.singletonList(new BranchSpec("refs/heads/foo")))) .setScmConfigs(scmConfigFactory.createERs(gitUrl, "refs/heads/foo")) .setShouldStarted(false) }, { "no job scm configured", new ProjectFixture() .setSendBranches("refs/heads/foo") .setScmConfigs(scmConfigFactory.createERs(defaultSCMUrl, "refs/heads/foo")) .setShouldStarted(true) }, }); }
Example #14
Source File: DeflakeGitBuildChooserTest.java From flaky-test-handler-plugin with Apache License 2.0 | 5 votes |
private FreeStyleProject setupProject(List<BranchSpec> specs) throws Exception { FreeStyleProject project = setupProject(specs, false, null, null, null, null, false, null); assertNotNull("could not init project", project); // Use DeflakeGitBuildChooser DeflakeGitBuildChooser chooser = new DeflakeGitBuildChooser(); chooser.gitSCM = (GitSCM) project.getScm(); chooser.gitSCM.setBuildChooser(chooser); return project; }
Example #15
Source File: GitLabSCMMergeRequestHead.java From gitlab-branch-source-plugin with GNU General Public License v2.0 | 5 votes |
@Nonnull @Override List<BranchSpec> getBranchSpecs() { if (!merge) { return super.getBranchSpecs(); } List<BranchSpec> branches = new ArrayList<>(2); branches.addAll(super.getBranchSpecs()); branches.add(new BranchSpec(targetBranch.getRef())); return branches; }
Example #16
Source File: MockScmFactory.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 4 votes |
@Override public GitSCM createGit(String url, List<BranchSpec> branchSpecs) { return MockGitSCM.fromUrlAndBranchSpecs(url, branchSpecs); }
Example #17
Source File: GitLabSCMHeadImpl.java From gitlab-branch-source-plugin with GNU General Public License v2.0 | 4 votes |
@Nonnull List<BranchSpec> getBranchSpecs() { return singletonList(new BranchSpec(getRef())); }
Example #18
Source File: ScmFactory.java From aws-codecommit-trigger-plugin with Apache License 2.0 | votes |
GitSCM createGit(String url, List<BranchSpec> branchSpecs);