• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java GitSCMExtension类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中hudson.plugins.git.extensions.GitSCMExtension的典型用法代码示例。如果您正苦于以下问题:Java GitSCMExtension类的具体用法?Java GitSCMExtension怎么用?Java GitSCMExtension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GitSCMExtension类属于hudson.plugins.git.extensions包,在下文中一共展示了GitSCMExtension类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: decorateRevisionToBuild

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
@Override
public Revision decorateRevisionToBuild(GitSCM scm, Run<?, ?> build, GitClient git, TaskListener listener, Revision marked, Revision rev) throws IOException, InterruptedException, GitException {
    listener.getLogger().println("Merging " + targetBranch.getName() + " commit " + targetBranch.getRevision().getHash() + " into merge-request head commit " + rev.getSha1String());
    checkout(scm, build, git, listener, rev);
    try {
        git.setAuthor("Jenkins", /* could parse out of JenkinsLocationConfiguration.get().getAdminAddress() but seems overkill */"[email protected]");
        git.setCommitter("Jenkins", "[email protected]");
        MergeCommand cmd = git.merge().setRevisionToMerge(ObjectId.fromString(targetBranch.getRevision().getHash()));
        for (GitSCMExtension ext : scm.getExtensions()) {
            // By default we do a regular merge, allowing it to fast-forward.
            ext.decorateMergeCommand(scm, build, git, listener, cmd);
        }
        cmd.execute();
    } catch (GitException e) {
        // Try to revert merge conflict markers.
        checkout(scm, build, git, listener, rev);
        throw e;
    }
    build.addAction(new MergeRecord(targetBranch.getRefSpec().destinationRef(targetBranch.getName()), targetBranch.getRevision().getHash())); // does not seem to be used, but just in case
    ObjectId mergeRev = git.revParse(Constants.HEAD);
    listener.getLogger().println("Merge succeeded, producing " + mergeRev.name());
    return new Revision(mergeRev, rev.getBranches()); // note that this ensures Build.revision != Build.marked
}
 
开发者ID:Argelbargel,项目名称:gitlab-branch-source-plugin,代码行数:24,代码来源:GitLabSCMMergeRequestHead.java


示例2: setupProject

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
protected FreeStyleProject setupProject(List<BranchSpec> branches, boolean authorOrCommitter,
    String relativeTargetDir, String excludedRegions,
    String excludedUsers, String localBranch, boolean fastRemotePoll,
    String includedRegions, List<SparseCheckoutPath> sparseCheckoutPaths) throws Exception {
  FreeStyleProject project = createFreeStyleProject();
  GitSCM scm = new GitSCM(
      createRemoteRepositories(),
      branches,
      false, Collections.<SubmoduleConfig>emptyList(),
      null, null,
      Collections.<GitSCMExtension>emptyList());
  scm.getExtensions().add(new DisableRemotePoll()); // don't work on a file:// repository
  if (relativeTargetDir!=null)
    scm.getExtensions().add(new RelativeTargetDirectory(relativeTargetDir));
  if (excludedUsers!=null)
    scm.getExtensions().add(new UserExclusion(excludedUsers));
  if (excludedRegions!=null || includedRegions!=null)
    scm.getExtensions().add(new PathRestriction(includedRegions,excludedRegions));

  scm.getExtensions().add(new SparseCheckoutPaths(sparseCheckoutPaths));

  project.setScm(scm);
  project.getBuildersList().add(new CaptureEnvironmentBuilder());
  return project;
}
 
开发者ID:jenkinsci,项目名称:flaky-test-handler-plugin,代码行数:26,代码来源:AbstractGitTestCase.java


示例3: GitBackend

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
public GitBackend(AbstractBuild build, Launcher launcher, BuildListener listener, GitSCM scm) throws Exception {
    this.build = build;
    this.launcher = launcher;
    this.listener = listener;
    this.scm = scm;
    FilePath path = build.getWorkspace();
    EnvVars environment = build.getEnvironment(listener);
    for (GitSCMExtension ext : scm.getExtensions()) {
        FilePath r = ext.getWorkingDirectory(scm, build.getParent(), path, environment, listener);
        if (r!=null) {
            path = r;
        }
    }
    this.git = new AdvancedCliGit(
            scm, launcher, build.getBuiltOn(), new File(path.absolutize().getRemote()), listener,
            build.getEnvironment(listener));
    this.repoPath = git.getWorkTree();
}
 
开发者ID:jenkinsci,项目名称:gatekeeper-plugin,代码行数:19,代码来源:GitBackend.java


示例4: configurePretestedIntegrationPlugin

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
private FreeStyleProject configurePretestedIntegrationPlugin(IntegrationStrategy integrationStrategy, String repositoryUrl) throws IOException, ANTLRException, InterruptedException {
    FreeStyleProject project = jenkinsRule.createFreeStyleProject();

    List<UserRemoteConfig> repoList = new ArrayList<>();
    repoList.add(new UserRemoteConfig(repositoryUrl, null, null, null));

    List<GitSCMExtension> gitSCMExtensions = new ArrayList<>();
    gitSCMExtensions.add(new PretestedIntegrationAsGitPluginExt(integrationStrategy, "master", "origin"));
    gitSCMExtensions.add(new PruneStaleBranch());
    gitSCMExtensions.add(new CleanCheckout());

    GitSCM gitSCM = new GitSCM(repoList,
            Collections.singletonList(new BranchSpec("origin/ready/**")),
            false, Collections.<SubmoduleConfig>emptyList(),
            null, null, gitSCMExtensions);

    project.setScm(gitSCM);
    project.getPublishersList().add(new PretestedIntegrationPostCheckout());
    return project;
}
 
开发者ID:Praqma,项目名称:pretested-integration-plugin,代码行数:21,代码来源:TwoBranchHeadsIT.java


示例5: configurePretestedIntegrationPlugin

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
public static FreeStyleProject configurePretestedIntegrationPlugin(JenkinsRule rule, STRATEGY_TYPE type, List<UserRemoteConfig> repoList, String repoName, boolean runOnSlave, String integrationBranch) throws Exception {
    FreeStyleProject project = rule.createFreeStyleProject();
    if (runOnSlave) {
        DumbSlave onlineSlave = rule.createOnlineSlave();
        project.setAssignedNode(onlineSlave);
    }


    List<GitSCMExtension> gitSCMExtensions = new ArrayList<>();
    gitSCMExtensions.add(new PretestedIntegrationAsGitPluginExt(type == STRATEGY_TYPE.SQUASH ? new SquashCommitStrategy() : new AccumulatedCommitStrategy(), integrationBranch, repoName));
    gitSCMExtensions.add(new PruneStaleBranch());
    gitSCMExtensions.add(new CleanCheckout());

    project.getPublishersList().add(new PretestedIntegrationPostCheckout());

    GitSCM gitSCM = new GitSCM(repoList,
            Collections.singletonList(new BranchSpec("*/ready/**")),
            false, Collections.<SubmoduleConfig>emptyList(),
            null, null, gitSCMExtensions);


    project.setScm(gitSCM);
    project.save();

    return project;
}
 
开发者ID:Praqma,项目名称:pretested-integration-plugin,代码行数:27,代码来源:TestUtilsFactory.java


示例6: createGit

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
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()
    );
}
 
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:12,代码来源:ScmFactoryImpl.java


示例7: fromUrlAndBranchSpecs

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
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()
    );
}
 
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:12,代码来源:MockGitSCM.java


示例8: setExtensions

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
@Restricted(DoNotUse.class)
@DataBoundSetter
public void setExtensions(@CheckForNull List<GitSCMExtension> extensions) {
  List<SCMSourceTrait> traits = new ArrayList<>(this.traits);
  for (Iterator<SCMSourceTrait> iterator = traits.iterator(); iterator.hasNext(); ) {
    if (iterator.next() instanceof GitSCMExtensionTrait) {
      iterator.remove();
    }
  }
  EXTENSIONS:
  for (GitSCMExtension extension : Util.fixNull(extensions)) {
    for (SCMSourceTraitDescriptor d : SCMSourceTrait.all()) {
      if (d instanceof GitSCMExtensionTraitDescriptor) {
        GitSCMExtensionTraitDescriptor descriptor = (GitSCMExtensionTraitDescriptor) d;
        if (descriptor.getExtensionClass().isInstance(extension)) {
          try {
            SCMSourceTrait trait = descriptor.convertToTrait(extension);
            if (trait != null) {
              traits.add(trait);
              continue EXTENSIONS;
            }
          } catch (UnsupportedOperationException e) {
            LOGGER.log(
                Level.WARNING,
                "Could not convert " + extension.getClass().getName() + " to a trait",
                e);
          }
        }
      }
      LOGGER.log(
          Level.FINE,
          "Could not convert {0} to a trait (likely because this option does not "
              + "make sense for a GitSCMSource)",
          extension.getClass().getName());
    }
  }
  setTraits(traits);
}
 
开发者ID:GerritForge,项目名称:gerrit-plugin,代码行数:39,代码来源:GerritSCMSource.java


示例9: checkout

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
private void checkout(GitSCM scm, Run<?, ?> build, GitClient git, TaskListener listener, Revision rev) throws InterruptedException, IOException, GitException {
    CheckoutCommand checkoutCommand = git.checkout().ref(rev.getSha1String());
    for (GitSCMExtension ext : scm.getExtensions()) {
        ext.decorateCheckoutCommand(scm, build, git, listener, checkoutCommand);
    }
    checkoutCommand.execute();
}
 
开发者ID:Argelbargel,项目名称:gitlab-branch-source-plugin,代码行数:8,代码来源:GitLabSCMMergeRequestHead.java


示例10: testGitSCMWithSomeExtensionJob

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
@Test public void testGitSCMWithSomeExtensionJob() throws Exception {
    FreeStyleProject project = j.createFreeStyleProject();
    ArrayList<GitSCMExtension> extensions = new ArrayList<GitSCMExtension>();
    extensions.add(new CleanCheckout());
    project.setScm(new hudson.plugins.git.GitSCM(null, null, false, null, null, "", extensions));
    assertTrue(checker.executeCheck(project));
    extensions.add(new CloneOption(false, "", 0));
    project.setScm(new hudson.plugins.git.GitSCM(null, null, false, null, null, "", extensions));
    assertTrue(checker.executeCheck(project));
}
 
开发者ID:v1v,项目名称:jenkinslint-plugin,代码行数:11,代码来源:GitShallowCheckerTestCase.java


示例11: testGitSCMWithCloneOptionExtensionNoShallowJob

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
@Test public void testGitSCMWithCloneOptionExtensionNoShallowJob() throws Exception {
    FreeStyleProject project = j.createFreeStyleProject();
    ArrayList<GitSCMExtension> extensions = new ArrayList<GitSCMExtension>();
    extensions.add(new CloneOption(false, "", 0));
    project.setScm(new hudson.plugins.git.GitSCM(null, null, false, null, null, "", extensions));
    assertTrue(checker.executeCheck(project));
}
 
开发者ID:v1v,项目名称:jenkinslint-plugin,代码行数:8,代码来源:GitShallowCheckerTestCase.java


示例12: testGitSCMWithCloneOptionExtensionShallowJob

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
@Test public void testGitSCMWithCloneOptionExtensionShallowJob() throws Exception {
    FreeStyleProject project = j.createFreeStyleProject();
    ArrayList<GitSCMExtension> extensions = new ArrayList<GitSCMExtension>();
    extensions.add(new CloneOption(true, "", 0));
    project.setScm(new hudson.plugins.git.GitSCM(null, null, false, null, null, "", extensions));
    assertFalse(checker.executeCheck(project));
}
 
开发者ID:v1v,项目名称:jenkinslint-plugin,代码行数:8,代码来源:GitShallowCheckerTestCase.java


示例13: remoteOrigin1WithMoreThan1RepoShouldBeSuccessfulFirstRepo

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
/**
 * Git Plugin
 * <p>
 * Test that we operate using a default configuration, with two repositories
 * in a single Git Plugin configuration.
 * <p>
 * Pretested integration:
 * - 'Integration branch' : master (default)
 * - 'Repository name' : origin1
 * - 'Strategy' : Accumulated commit
 * <p>
 * GitSCM:
 * - 'Name' : origin1
 * - 'Name' : magic
 * <p>
 * Workflow
 * - Create two repositories each containing a 'ready' branch.
 * - The build is triggered.
 * <p>
 * Results
 * - One Build. That should be successful.
 *
 * @throws Exception
 */
@Test
public void remoteOrigin1WithMoreThan1RepoShouldBeSuccessfulFirstRepo() throws Exception {
    Repository repository = TestUtilsFactory.createValidRepository("test-repo");
    Repository repository2 = TestUtilsFactory.createValidRepository("test-repo2");

    List<UserRemoteConfig> config = Arrays.asList(new UserRemoteConfig("file://" + repository.getDirectory().getAbsolutePath(), "origin1", null, null), new UserRemoteConfig("file://" + repository2.getDirectory().getAbsolutePath(), "magic", null, null));

    List<GitSCMExtension> gitSCMExtensions = new ArrayList<>();
    gitSCMExtensions.add(new PruneStaleBranch());
    gitSCMExtensions.add(new CleanCheckout());

    GitSCM gitSCM = new GitSCM(config,
            Collections.singletonList(new BranchSpec("*/ready/**")),
            false, Collections.<SubmoduleConfig>emptyList(),
            null, null, gitSCMExtensions);

    FreeStyleProject project = TestUtilsFactory.configurePretestedIntegrationPlugin(jenkinsRule, TestUtilsFactory.STRATEGY_TYPE.ACCUMULATED, config, "origin1", true);
    project.setScm(gitSCM);
    TestUtilsFactory.triggerProject(project);

    assertEquals(1, jenkinsRule.jenkins.getQueue().getItems().length);

    jenkinsRule.waitUntilNoActivityUpTo(60000);

    int nextBuildNumber = project.getNextBuildNumber();
    FreeStyleBuild build = project.getBuildByNumber(nextBuildNumber - 1);

    //Show the log for the latest build
    String text = jenkinsRule.createWebClient().getPage(build, "console").asText();
    System.out.println("=====BUILD-LOG=====");
    System.out.println(text);
    System.out.println("=====BUILD-LOG=====");

    assertTrue(build.getResult().isWorseOrEqualTo(Result.SUCCESS));
    TestUtilsFactory.destroyRepo(repository2, repository);
}
 
开发者ID:Praqma,项目名称:pretested-integration-plugin,代码行数:61,代码来源:GeneralBehaviourIT.java


示例14: remoteOrigin1WithMoreThan1RepoShouldBeSuccessfulSecondRepo

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
/**
 * Git Plugin
 * <p>
 * Test that we operate using a default configuration, with two repositories
 * in a single Git Plugin configuration.
 * <p>
 * Pretested integration:
 * - 'Integration branch' : master (default)
 * - 'Repository name' : origin1
 * - 'Strategy' : Accumulated commit
 * <p>
 * GitSCM:
 * - 'Name' : magic
 * - 'Name' : origin1
 * <p>
 * Workflow
 * - Create two repositories each containing a 'ready' branch.
 * - The build is triggered.
 * <p>
 * Results
 * - One Build. That should be successful. We merge feature_1 from origin1 into
 * master.
 *
 * @throws Exception
 */
@Test
public void remoteOrigin1WithMoreThan1RepoShouldBeSuccessfulSecondRepo() throws Exception {
    Repository repository = TestUtilsFactory.createValidRepository("test-repo");
    Repository repository2 = TestUtilsFactory.createValidRepository("test-repo2");

    List<UserRemoteConfig> config = Arrays.asList(new UserRemoteConfig("file://" + repository.getDirectory().getAbsolutePath(), "magic", null, null), new UserRemoteConfig("file://" + repository2.getDirectory().getAbsolutePath(), "orgin1", null, null));

    List<GitSCMExtension> gitSCMExtensions = new ArrayList<>();
    gitSCMExtensions.add(new PruneStaleBranch());
    gitSCMExtensions.add(new CleanCheckout());

    GitSCM gitSCM = new GitSCM(config,
            Collections.singletonList(new BranchSpec("*/ready/**")),
            false, Collections.<SubmoduleConfig>emptyList(),
            null, null, gitSCMExtensions);

    FreeStyleProject project = TestUtilsFactory.configurePretestedIntegrationPlugin(jenkinsRule, TestUtilsFactory.STRATEGY_TYPE.ACCUMULATED, config, "origin1", true);
    project.setScm(gitSCM);
    TestUtilsFactory.triggerProject(project);

    assertEquals(1, jenkinsRule.jenkins.getQueue().getItems().length);

    jenkinsRule.waitUntilNoActivityUpTo(60000);

    TestUtilsFactory.destroyRepo(repository, repository2);

    int nextBuildNumber = project.getNextBuildNumber();
    FreeStyleBuild build = project.getBuildByNumber(nextBuildNumber - 1);

    //Show the log for the latest build
    String text = jenkinsRule.createWebClient().getPage(build, "console").asText();
    System.out.println("=====BUILD-LOG=====");
    System.out.println(text);
    System.out.println("=====BUILD-LOG=====");

    assertTrue(build.getResult().isWorseOrEqualTo(Result.SUCCESS));
}
 
开发者ID:Praqma,项目名称:pretested-integration-plugin,代码行数:63,代码来源:GeneralBehaviourIT.java


示例15: MockGitSCM

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
@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();
}
 
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:6,代码来源:MockGitSCM.java


示例16: getExtensions

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
@Nonnull
List<GitSCMExtension> getExtensions(GitLabSCMSource source) {
    return emptyList();
}
 
开发者ID:Argelbargel,项目名称:gitlab-branch-source-plugin,代码行数:5,代码来源:GitLabSCMHeadImpl.java


示例17: getExtensions

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
@Nonnull
@Override
List<GitSCMExtension> getExtensions(GitLabSCMSource source) {
    return merge ? Collections.<GitSCMExtension>singletonList(new MergeWith()) : Collections.<GitSCMExtension>emptyList();
}
 
开发者ID:Argelbargel,项目名称:gitlab-branch-source-plugin,代码行数:6,代码来源:GitLabSCMMergeRequestHead.java


示例18: mapBuildConfigToFlow

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
public static FlowDefinition mapBuildConfigToFlow(BuildConfig bc) throws IOException {
	if (!OpenShiftUtils.isPipelineStrategyBuildConfig(bc)) {
		return null;
	}

	BuildConfigSpec spec = bc.getSpec();
	BuildSource source = null;
	String jenkinsfile = null;
	String jenkinsfilePath = null;
	if (spec != null) {
		source = spec.getSource();
		BuildStrategy strategy = spec.getStrategy();
		if (strategy != null) {
			JenkinsPipelineBuildStrategy jenkinsPipelineStrategy = strategy.getJenkinsPipelineStrategy();
			if (jenkinsPipelineStrategy != null) {
				jenkinsfile = jenkinsPipelineStrategy.getJenkinsfile();
				jenkinsfilePath = jenkinsPipelineStrategy.getJenkinsfilePath();
			}
		}
	}
	if (jenkinsfile == null) {
		// Is this a Jenkinsfile from Git SCM?
		if (source != null && source.getGit() != null && source.getGit().getUri() != null) {
			if (jenkinsfilePath == null) {
				jenkinsfilePath = DEFAULT_JENKINS_FILEPATH;
			}
			if (!isEmpty(source.getContextDir())) {
				jenkinsfilePath = new File(source.getContextDir(), jenkinsfilePath).getPath();
			}
			GitBuildSource gitSource = source.getGit();
			String branchRef = gitSource.getRef();
			List<BranchSpec> branchSpecs = Collections.emptyList();
			if (isNotBlank(branchRef)) {
				branchSpecs = Collections.singletonList(new BranchSpec(branchRef));
			}
			String credentialsId = updateSourceCredentials(bc);
			// if credentialsID is null, go with an SCM where anonymous has to be sufficient
			GitSCM scm = new GitSCM(
					Collections.singletonList(new UserRemoteConfig(gitSource.getUri(), null, null, credentialsId)),
					branchSpecs, false, Collections.<SubmoduleConfig>emptyList(), null, null,
					Collections.<GitSCMExtension>emptyList());
			return new CpsScmFlowDefinition(scm, jenkinsfilePath);
		} else {
			LOGGER.warning("BuildConfig does not contain source repository information - "
					+ "cannot map BuildConfig to Jenkins job");
			return null;
		}
	} else {
		return new CpsFlowDefinition(jenkinsfile, true);
	}
}
 
开发者ID:jenkinsci,项目名称:openshift-sync-plugin,代码行数:52,代码来源:BuildConfigToJobMapper.java


示例19: testGitSCMWithEmptyExtensionJob

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
@Test public void testGitSCMWithEmptyExtensionJob() throws Exception {
    FreeStyleProject project = j.createFreeStyleProject();
    ArrayList<GitSCMExtension> extensions = new ArrayList<GitSCMExtension>();
    project.setScm(new hudson.plugins.git.GitSCM(null, null, false, null, null, "", extensions));
    assertTrue(checker.executeCheck(project));
}
 
开发者ID:v1v,项目名称:jenkinslint-plugin,代码行数:7,代码来源:GitShallowCheckerTestCase.java


示例20: getManager

import hudson.plugins.git.extensions.GitSCMExtension; //导入依赖的package包/类
public static AdvancedSCMManager getManager(AbstractBuild build, Launcher launcher, BuildListener listener) throws Exception {
    String givenRepoSubdir = null;
    PrintStream l = listener.getLogger();
    givenRepoSubdir = build.getEnvironment(listener).get("REPO_SUBDIR", "");
    SCM scm = build.getProject().getScm();

    // Sort out multiscm scms.
    if (scm instanceof MultiSCM) {
        List<SCM> scms = ((MultiSCM) scm).getConfiguredSCMs();
        if (scms.size() > 1) {
            // loop and find correct repo to apply credentials on
            for (SCM s: ((MultiSCM) scm).getConfiguredSCMs()) {
                // Only if typeof scm is mercurial
                if (s instanceof MercurialSCM) {
                    String subDir = ((MercurialSCM) s).getSubdir();
                    if (subDir != null) {
                        if (subDir.equals(givenRepoSubdir)) {
                            l.append("Chosen MultiSCM with Mercurial Backend");
                            return new MercurialBackend(build, launcher, listener, (MercurialSCM) s);
                        }
                    }
                } else if (s instanceof GitSCM) {
                    GitSCM gitSCM = (GitSCM) s;

                    for (GitSCMExtension extension: gitSCM.getExtensions()){
                        if (extension instanceof RelativeTargetDirectory) {
                            String targetDir = ((RelativeTargetDirectory) extension).getRelativeTargetDir();
                            if (targetDir  != null && !targetDir .isEmpty() && targetDir == givenRepoSubdir) {
                                l.append("Chosen MultiSCM with Git Backend");
                                return new GitBackend(build, launcher, listener, (GitSCM) s);
                            }
                        }
                    }
                }
            }
        } else {
            scm = scms.get(0);
        }
    }

    // No multiscm, just return correct backend.
    if (scm instanceof MercurialSCM) {
        l.append("Chosen Mercurial backend, NO MultiSCM");
        return new MercurialBackend(build, launcher, listener, (MercurialSCM) scm);
    } else if (scm instanceof GitSCM) {
        l.append("Chosen Git backend, NO MultiSCM");
        return new GitBackend(build, launcher, listener, (GitSCM) scm);
    }

    // If we come here, no viable SCM was found, so we quit.
    throw new Exception("There is no implementation available for the chosen SCM. Sorry about that.");
}
 
开发者ID:jenkinsci,项目名称:gatekeeper-plugin,代码行数:53,代码来源:SCMManagerFactory.java



注:本文中的hudson.plugins.git.extensions.GitSCMExtension类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WsaActionUtil类代码示例发布时间:2022-05-22
下一篇:
Java AuthenticationStatus类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap