本文整理汇总了Java中hudson.plugins.git.extensions.GitSCMExtension类的典型用法代码示例。如果您正苦于以下问题:Java GitSCMExtension类的具体用法?Java GitSCMExtension怎么用?Java GitSCMExtension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GitSCMExtension类属于hudson.plugins.git.extensions包,在下文中一共展示了GitSCMExtension类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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()
);
}
示例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()
);
}
示例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);
}
示例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();
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}
示例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));
}
示例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();
}