本文整理汇总了Java中hudson.plugins.git.BranchSpec类的典型用法代码示例。如果您正苦于以下问题:Java BranchSpec类的具体用法?Java BranchSpec怎么用?Java BranchSpec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BranchSpec类属于hudson.plugins.git包,在下文中一共展示了BranchSpec类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getBranch
import hudson.plugins.git.BranchSpec; //导入依赖的package包/类
private String getBranch(SCM scm) {
if (scm instanceof GitSCM) {
GitSCM gitScm = (GitSCM) scm;
StringBuilder builder = new StringBuilder();
for (BranchSpec spec : gitScm.getBranches()) {
if (builder.length() > 0) {
builder.append(", ");
}
builder.append(spec.getName());
}
return builder.toString();
}
// here we can try to get branch from other SCM
return "undetermined";
}
开发者ID:Microsoft,项目名称:vsts-jenkins-build-integration-sample,代码行数:18,代码来源:TfsBuildFacadeFactoryImpl.java
示例2: testDeflakeCheckoutFailingRevision
import hudson.plugins.git.BranchSpec; //导入依赖的package包/类
@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());
}
开发者ID:jenkinsci,项目名称:flaky-test-handler-plugin,代码行数:21,代码来源:DeflakeGitBuildChooserTest.java
示例3: configurePretestedIntegrationPlugin
import hudson.plugins.git.BranchSpec; //导入依赖的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
示例4: configurePretestedIntegrationPlugin
import hudson.plugins.git.BranchSpec; //导入依赖的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
示例5: matchBranch
import hudson.plugins.git.BranchSpec; //导入依赖的package包/类
private boolean matchBranch(final Event event, final List<BranchSpec> branchSpecs) {//TODO use it
for (BranchSpec branchSpec : branchSpecs) {
if (branchSpec.matches(event.getBranch())) {
log.debug("Event %s matched branch %s", event.getArn(), branchSpec.getName());
return true;
}
}
log.debug("Found no event matched any branch", event.getArn());
return false;
}
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:12,代码来源:ScmJobEventTriggerMatcher.java
示例6: fromSqsJob
import hudson.plugins.git.BranchSpec; //导入依赖的package包/类
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;
}
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:40,代码来源:RepoInfo.java
示例7: getBranchSpecs
import hudson.plugins.git.BranchSpec; //导入依赖的package包/类
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;
}
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:11,代码来源:SQSScmConfig.java
示例8: createGit
import hudson.plugins.git.BranchSpec; //导入依赖的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
示例9: fromUrlAndBranchSpecs
import hudson.plugins.git.BranchSpec; //导入依赖的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
示例10: fromSqsMessage
import hudson.plugins.git.BranchSpec; //导入依赖的package包/类
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);
}
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:9,代码来源:MockGitSCM.java
示例11: fixtures
import hudson.plugins.git.BranchSpec; //导入依赖的package包/类
@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)
},
});
}
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:40,代码来源:JenkinsIT.java
示例12: fixtures
import hudson.plugins.git.BranchSpec; //导入依赖的package包/类
@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)
},
});
}
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:38,代码来源:JenkinsERIT.java
示例13: fixtures
import hudson.plugins.git.BranchSpec; //导入依赖的package包/类
@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)
}
});
}
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:34,代码来源:JenkinsIRIT.java
示例14: getBranchSpecs
import hudson.plugins.git.BranchSpec; //导入依赖的package包/类
@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;
}
开发者ID:Argelbargel,项目名称:gitlab-branch-source-plugin,代码行数:13,代码来源:GitLabSCMMergeRequestHead.java
示例15: populateFromGitSCM
import hudson.plugins.git.BranchSpec; //导入依赖的package包/类
private static boolean populateFromGitSCM(BuildConfig buildConfig, BuildSource source, GitSCM gitSCM, String ref) {
source.setType("Git");
List<RemoteConfig> repositories = gitSCM.getRepositories();
if (repositories != null && repositories.size() > 0) {
RemoteConfig remoteConfig = repositories.get(0);
List<URIish> urIs = remoteConfig.getURIs();
if (urIs != null && urIs.size() > 0) {
URIish urIish = urIs.get(0);
String gitUrl = urIish.toString();
if (gitUrl != null && gitUrl.length() > 0) {
if (StringUtils.isEmpty(ref)) {
List<BranchSpec> branches = gitSCM.getBranches();
if (branches != null && branches.size() > 0) {
BranchSpec branchSpec = branches.get(0);
String branch = branchSpec.getName();
while (branch.startsWith("*") || branch.startsWith("/")) {
branch = branch.substring(1);
}
if (!branch.isEmpty()) {
ref = branch;
}
}
}
OpenShiftUtils.updateGitSourceUrl(buildConfig, gitUrl, ref);
return true;
}
}
}
return false;
}
开发者ID:jenkinsci,项目名称:openshift-sync-plugin,代码行数:31,代码来源:BuildConfigToJobMapper.java
示例16: provideGitSCM
import hudson.plugins.git.BranchSpec; //导入依赖的package包/类
public static GitSCM provideGitSCM() {
return new GitSCM(newArrayList(
new UserRemoteConfig("https://github.com/user/dropwizard",
"", "+refs/pull/*:refs/remotes/origin/pr/*", "")),
newArrayList(new BranchSpec("${sha1}")),
false,
null,
null,
"",
null);
}
开发者ID:bratchenko,项目名称:jenkins-github-pull-request-comments,代码行数:12,代码来源:GhprcTestUtil.java
示例17: setupProject
import hudson.plugins.git.BranchSpec; //导入依赖的package包/类
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;
}
开发者ID:jenkinsci,项目名称:flaky-test-handler-plugin,代码行数:12,代码来源:DeflakeGitBuildChooserTest.java
示例18: testBasicMerge
import hudson.plugins.git.BranchSpec; //导入依赖的package包/类
@Test
public void testBasicMerge() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
List<UserRemoteConfig> remotes = new ArrayList<UserRemoteConfig>();
remotes.add(new UserRemoteConfig(repo.getPath(), "origin", "master", null));
List<BranchSpec> branches = new ArrayList<BranchSpec>();
branches.add(new BranchSpec("master"));
p.setScm(new GitSCM(remotes, branches, false, null, null, null, null));
// Init repo with release and feature branch.
GitClient client = g.gitClient(repo);
client.init();
g.touchAndCommit(repo, "init");
client.checkout("HEAD", "r1336");
g.touchAndCommit(repo, "r1336");
client.checkout("HEAD", "c3");
g.touchAndCommit(repo, "c3");
// Custom builder that merges feature branch with release branch using AdvancedSCMManager.
p.getBuildersList().add(new TestBuilder() {
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
try {
AdvancedSCMManager amm = SCMManagerFactory.getManager(build, launcher, listener);
amm.update("r1336");
amm.mergeWorkspaceWith("c3", null);
amm.commit("merge c3", "test <[email protected]>");
return true;
} catch (Exception e) {
e.printStackTrace(listener.getLogger());
return false;
}
}
});
// Assert file is here (should be after successful merge)
g.buildAndCheck(p, "c3");
}
开发者ID:jenkinsci,项目名称:gatekeeper-plugin,代码行数:39,代码来源:BasicGitTest.java
示例19: createRevisionParameterAction_pushCommitRequestWith2Remotes
import hudson.plugins.git.BranchSpec; //导入依赖的package包/类
@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().createRevisionParameter(hook, gitSCM);
assertThat(revisionParameterAction, is(notNullValue()));
assertThat(revisionParameterAction.commit, is(hook.getAfter()));
assertFalse(revisionParameterAction.canOriginateFrom(new ArrayList<RemoteConfig>()));
}
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:16,代码来源:PushHookTriggerHandlerGitlabServerTest.java
示例20: remoteOrigin1WithMoreThan1RepoShouldBeSuccessfulFirstRepo
import hudson.plugins.git.BranchSpec; //导入依赖的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
注:本文中的hudson.plugins.git.BranchSpec类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论