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