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

Java SCMHead类代码示例

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

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



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

示例1: isExcluded

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean isExcluded(@NonNull SCMSourceRequest request, @NonNull SCMHead head) {
    if (head instanceof BranchSCMHead && request instanceof GiteaSCMSourceRequest) {
        for (GiteaPullRequest p : ((GiteaSCMSourceRequest) request).getPullRequests()) {
            // only match if the pull request is an origin pull request
            if (p.getBase().getRepo().getOwner().getUsername()
                    .equalsIgnoreCase(p.getHead().getRepo().getOwner().getUsername())
                    && p.getBase().getRepo().getName().equalsIgnoreCase(p.getHead().getRepo().getName())
                    && p.getHead().getRef().equals(head.getName())) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:19,代码来源:BranchDiscoveryTrait.java


示例2: given__child_file__when__content__then__contents_returned

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
@Test
public void given__child_file__when__content__then__contents_returned() throws Exception {
    ASFGitSCMFileSystem fs = new ASFGitSCMFileSystem(serverRootUrl + "/maven.git", new SCMHead("master"), null);
    assertThat(fs.getRoot().child(".gitignore").contentAsString(), is("target/\n"
            + ".project\n"
            + ".classpath\n"
            + ".settings/\n"
            + ".svn/\n"
            + "bin/\n"
            + "# Intellij\n"
            + "*.ipr\n"
            + "*.iml\n"
            + ".idea\n"
            + "out/\n"
            + ".DS_Store\n"
            + "/bootstrap\n"
            + "/dependencies.xml\n"
            + ".java-version\n"));
}
 
开发者ID:stephenc,项目名称:asf-gitpubsub-jenkins-plugin,代码行数:20,代码来源:ASFGitSCMFileTest.java


示例3: isAutomaticBuild

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
@SuppressWarnings("SimplifiableIfStatement")
private boolean isAutomaticBuild(GitLabSCMSource source, SCMHead head) {
    if (head instanceof TagSCMHead) {
        return source.getSourceSettings().getTagMonitorStrategy().getBuild();
    }

    if (head instanceof GitLabSCMBranchHead) {
        return !((GitLabSCMBranchHead) head).hasMergeRequest() || source.getSourceSettings().getBranchMonitorStrategy().getBuildBranchesWithMergeRequests();
    }

    if (head instanceof GitLabSCMMergeRequestHead) {
        return isAutomaticBuild(source, (GitLabSCMMergeRequestHead) head);
    }

    return true;
}
 
开发者ID:Argelbargel,项目名称:gitlab-branch-source-plugin,代码行数:17,代码来源:GitLabSCMBranchBuildStrategy.java


示例4: retrieve

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
@Nonnull
private List<Action> retrieve(@Nonnull SCMRevisionImpl revision, @CheckForNull SCMHeadEvent event, @Nonnull TaskListener listener) throws IOException, InterruptedException {
    List<Action> actions = new ArrayList<>();

    String hash = revision.getHash();
    Action linkAction = GitLabLinkAction.toCommit(source.getProject(), hash);
    actions.add(linkAction);

    SCMHead head = revision.getHead();
    if (head instanceof GitLabSCMMergeRequestHead) {
        actions.add(createHeadMetadataAction(head.getName(), ((GitLabSCMMergeRequestHead) head).getSource(), hash, linkAction.getUrlName()));
    } else if (head instanceof GitLabSCMHead) {
        actions.add(createHeadMetadataAction(head.getName(), (GitLabSCMHead) head, hash, linkAction.getUrlName()));
    }

    if (event instanceof GitLabSCMEvent) {
        actions.add(new GitLabSCMCauseAction(((GitLabSCMEvent) event).getCause()));
    }

    return actions;
}
 
开发者ID:Argelbargel,项目名称:gitlab-branch-source-plugin,代码行数:22,代码来源:SourceActions.java


示例5: getBranch

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
@Nonnull
@Override
public Branch getBranch(@Nonnull P project) {
    BranchProjectProperty property = project.getProperty(BranchProjectProperty.class);

    /*
     * Ugly hackish stuff, in the event that the user configures a branch project directly, thereby removing the
     * BranchProjectProperty.  The property must exist and we can't bash the @Nonnull return value restriction!
     *
     * Fudge some generic Branch with the expectation that indexing will soon reset the Branch with proper values,
     * or that it will be converted to Branch.Dead and the guessed values for sourceId and properties won't matter.
     */
    if (property == null) {
        Branch branch = new Branch("unknown", new SCMHead(project.getDisplayName()), project.getScm(),
                Collections.<BranchProperty>emptyList());
        setBranch(project, branch);
        return branch;
    }

    return property.getBranch();
}
 
开发者ID:jenkinsci,项目名称:multi-branch-project-plugin,代码行数:22,代码来源:TemplateDrivenBranchProjectFactory.java


示例6: doRun

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected Result doRun(BuildListener listener)
    throws IOException, InterruptedException {

  // Attach an SCMRevisionAction with our revision
  {
    final SCMHead head = getParent().getBranch().getHead();
    final SCMSource source = getParent().getSource();
    final SCMRevision revision = source.fetch(head, listener);
    TestBuild.this.addAction(new SCMRevisionAction(checkNotNull(revision)));
  }

  try {
    project.innerItem.scheduleBuild2(0,
        new Cause.UpstreamCause(TestBuild.this)).get();
  } catch (ExecutionException e) {
    return Result.FAILURE;
  }
  return Result.SUCCESS;
}
 
开发者ID:jenkinsci,项目名称:yaml-project-plugin,代码行数:22,代码来源:TestBuild.java


示例7: build

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
@Override
public PerforceScm build(SCMHead head, SCMRevision revision) {
	if (head instanceof P4Head && revision instanceof P4Revision) {
		P4Head perforceHead = (P4Head) head;
		P4Revision perforceRevision = (P4Revision) revision;

		// Build workspace from 'head' paths
		List<P4Path> paths = perforceHead.getPaths();
		Workspace workspace = getWorkspace(paths);

		// Build populate from revision
		String pin = perforceRevision.getRef().toString();
		Populate populate = new GraphHybridImpl(true, pin, null);
		PerforceScm scm = new PerforceScm(getCredential(), workspace, null, populate, getBrowser());
		return scm;
	} else {
		throw new IllegalArgumentException("SCMHead and/or SCMRevision not a Perforce instance!");
	}
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:20,代码来源:GlobalLibraryScmSource.java


示例8: getPullRequest

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
public static PullRequestSCMHead getPullRequest(@Nonnull final Job job) throws Exception {
    PullRequestSCMHead head = (PullRequestSCMHead) SCMHead.HeadByItem.findHead(job);
    if (head == null) {
        throw new IllegalStateException("Build is not a pull request");
    }
    return head;
}
 
开发者ID:aaronjwhiteside,项目名称:pipeline-github,代码行数:8,代码来源:GitHubHelper.java


示例9: start

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
@Override
public void start(final WorkflowJob project, final boolean newInstance) {
    super.start(project, newInstance);
    // we only care about pull requests
    if (SCMHead.HeadByItem.findHead(project) instanceof PullRequestSCMHead) {
        DescriptorImpl.jobs.put(getKey(project), project);
    }
}
 
开发者ID:aaronjwhiteside,项目名称:pipeline-github,代码行数:9,代码来源:IssueCommentTrigger.java


示例10: getKey

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
private String getKey(final WorkflowJob project) {
    GitHubSCMSource scmSource = (GitHubSCMSource) SCMSource.SourceByItem.findSource(project);
    PullRequestSCMHead scmHead = (PullRequestSCMHead) SCMHead.HeadByItem.findHead(project);

    return String.format("%s/%s/%d",
            scmSource.getRepoOwner(),
            scmSource.getRepository(),
            scmHead.getNumber());
}
 
开发者ID:aaronjwhiteside,项目名称:pipeline-github,代码行数:10,代码来源:IssueCommentTrigger.java


示例11: forRun

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
@Nonnull
@Override
public Collection<GlobalVariable> forRun(final Run<?, ?> run) {
    if (run == null) {
        return Collections.emptyList();
    }
    SCMHead scmHead = SCMHead.HeadByItem.findHead(run.getParent());
    if (scmHead instanceof PullRequestSCMHead) {
        Collection<GlobalVariable> result = new LinkedList<>();
        result.add(new PullRequestGlobalVariable());
        return result;
    }
    return Collections.emptyList();
}
 
开发者ID:aaronjwhiteside,项目名称:pipeline-github,代码行数:15,代码来源:GitHubPipelineGlobalVariables.java


示例12: headsFor

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@NonNull
@Override
public Map<SCMHead, SCMRevision> headsFor(GiteaSCMSource source) {
    String ref = getPayload().getRef();
    ref = ref.startsWith(Constants.R_HEADS) ? ref.substring(Constants.R_HEADS.length()) : ref;
    BranchSCMHead h = new BranchSCMHead(ref);
    return Collections.<SCMHead, SCMRevision>singletonMap(h,
            StringUtils.isNotBlank(getPayload().getAfter())
                    ? new BranchSCMRevision(h, getPayload().getAfter()) : null);
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:14,代码来源:GiteaPushSCMEvent.java


示例13: GiteaSCMSourceRequest

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param source   the source.
 * @param context  the context.
 * @param listener the listener.
 */
GiteaSCMSourceRequest(SCMSource source, GiteaSCMSourceContext context, TaskListener listener) {
    super(source, context, listener);
    fetchBranches = context.wantBranches();
    fetchTags = context.wantTags();
    fetchOriginPRs = context.wantOriginPRs();
    fetchForkPRs = context.wantForkPRs();
    originPRStrategies = fetchOriginPRs && !context.originPRStrategies().isEmpty()
            ? Collections.unmodifiableSet(EnumSet.copyOf(context.originPRStrategies()))
            : Collections.<ChangeRequestCheckoutStrategy>emptySet();
    forkPRStrategies = fetchForkPRs && !context.forkPRStrategies().isEmpty()
            ? Collections.unmodifiableSet(EnumSet.copyOf(context.forkPRStrategies()))
            : Collections.<ChangeRequestCheckoutStrategy>emptySet();
    Set<SCMHead> includes = context.observer().getIncludes();
    if (includes != null) {
        Set<Long> pullRequestNumbers = new HashSet<>(includes.size());
        Set<String> branchNames = new HashSet<>(includes.size());
        Set<String> tagNames = new HashSet<>(includes.size());
        for (SCMHead h : includes) {
            if (h instanceof BranchSCMHead) {
                branchNames.add(h.getName());
            } else if (h instanceof PullRequestSCMHead) {
                pullRequestNumbers.add(Long.parseLong(((PullRequestSCMHead) h).getId()));
                if (SCMHeadOrigin.DEFAULT.equals(h.getOrigin())) {
                    branchNames.add(((PullRequestSCMHead) h).getOriginName());
                }
            } else if (h instanceof TagSCMHead) { // TODO replace with concrete class when tag support added
                tagNames.add(h.getName());
            }
        }
        this.requestedPullRequestNumbers = Collections.unmodifiableSet(pullRequestNumbers);
        this.requestedOriginBranchNames = Collections.unmodifiableSet(branchNames);
        this.requestedTagNames = Collections.unmodifiableSet(tagNames);
    } else {
        requestedPullRequestNumbers = null;
        requestedOriginBranchNames = null;
        requestedTagNames = null;
    }
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:46,代码来源:GiteaSCMSourceRequest.java


示例14: headsFor

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@NonNull
@Override
public Map<SCMHead, SCMRevision> headsFor(GiteaSCMSource source) {
    String ref = getPayload().getRef();
    ref = ref.startsWith(Constants.R_HEADS) ? ref.substring(Constants.R_HEADS.length()) : ref;
    BranchSCMHead h = new BranchSCMHead(ref);
    return Collections.<SCMHead, SCMRevision>singletonMap(h, new BranchSCMRevision(h, getPayload().getSha()));
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:12,代码来源:GiteaCreateSCMEvent.java


示例15: GiteaSCMBuilder

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param source   the {@link GiteaSCMSource}.
 * @param head     the {@link SCMHead}
 * @param revision the (optional) {@link SCMRevision}
 */
public GiteaSCMBuilder(@NonNull GiteaSCMSource source,
                       @NonNull SCMHead head, @CheckForNull SCMRevision revision) {
    super(
            head,
            revision,
            checkoutUriTemplate(null, source.getServerUrl(), null, null)
                    .set("owner", source.getRepoOwner())
                    .set("repository", source.getRepository())
                    .expand(),
            source.getCredentialsId()
    );
    this.context = source.getOwner();
    serverUrl = source.getServerUrl();
    repoOwner = source.getRepoOwner();
    repository = source.getRepository();
    sshRemote = source.getSshRemote();
    // now configure the ref specs
    withoutRefSpecs();
    String repoUrl;
    if (head instanceof PullRequestSCMHead) {
        PullRequestSCMHead h = (PullRequestSCMHead) head;
        withRefSpec("+refs/pull/" + h.getId() + "/head:refs/remotes/@{remote}/" + head
                .getName());
        repoUrl = repositoryUrl(h.getOriginOwner(), h.getOriginRepository());
    } else {
        withRefSpec("+refs/heads/" + head.getName() + ":refs/remotes/@{remote}/" + head.getName());
        repoUrl = repositoryUrl(repoOwner, repository);
    }
    // pre-configure the browser
    withBrowser(new GiteaBrowser(repoUrl));
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:39,代码来源:GiteaSCMBuilder.java


示例16: retrieve

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
@Override
protected SCMRevision retrieve(@NonNull SCMHead head, @NonNull TaskListener listener)
        throws IOException, InterruptedException {
    try (GiteaConnection c = gitea().open()) {
        if (head instanceof BranchSCMHead) {
            listener.getLogger().format("Querying the current revision of branch %s...%n", head.getName());
            String revision = c.fetchBranch(repoOwner, repository, head.getName()).getCommit().getId();
            listener.getLogger().format("Current revision of branch %s is %s%n", head.getName(), revision);
            return new BranchSCMRevision((BranchSCMHead) head, revision);
        } else if (head instanceof PullRequestSCMHead) {
            PullRequestSCMHead h = (PullRequestSCMHead) head;
            listener.getLogger().format("Querying the current revision of pull request #%s...%n", h.getId());
            GiteaPullRequest pr =
                    c.fetchPullRequest(repoOwner, repository, Long.parseLong(h.getId()));
            if (pr.getState() == GiteaIssueState.OPEN) {
                listener.getLogger().format("Current revision of pull request #%s is %s%n",
                        h.getId(), pr.getHead().getSha());
                return new PullRequestSCMRevision(
                        h,
                        new BranchSCMRevision(
                                h.getTarget(),
                                pr.getBase().getSha()
                        ),
                        new BranchSCMRevision(
                                new BranchSCMHead(h.getOriginName()),
                                pr.getHead().getSha()
                        )
                );
            } else {
                listener.getLogger().format("Pull request #%s is CLOSED%n", h.getId());
                return null;
            }
        } else {
            listener.getLogger().format("Unknown head: %s of type %s%n", head.getName(), head.getClass().getName());
            return null;
        }
    }
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:39,代码来源:GiteaSCMSource.java


示例17: retrieveRevisions

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
@NonNull
@Override
protected Set<String> retrieveRevisions(@NonNull TaskListener listener) throws IOException, InterruptedException {
    // don't pass through to git, instead use the super.super behaviour
    Set<String> revisions = new HashSet<String>();
    for (SCMHead head : retrieve(listener)) {
        revisions.add(head.getName());
    }
    return revisions;
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:11,代码来源:GiteaSCMSource.java


示例18: ASFGitSCMFileSystem

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param remote the remote.
 * @param head   the head.
 * @param rev    the revision.
 */
public ASFGitSCMFileSystem(String remote, SCMHead head, SCMRevision rev) {
    super(rev instanceof AbstractGitSCMSource.SCMRevisionImpl ? rev : null);
    this.remote = remote;
    this.refOrHash = rev instanceof AbstractGitSCMSource.SCMRevisionImpl
            ? ((AbstractGitSCMSource.SCMRevisionImpl) rev).getHash()
            : (head instanceof GitTagSCMHead
                    ? Constants.R_TAGS + head.getName()
                    : Constants.R_HEADS + head.getName());
}
 
开发者ID:stephenc,项目名称:asf-gitpubsub-jenkins-plugin,代码行数:17,代码来源:ASFGitSCMFileSystem.java


示例19: given__root__when__children__then__children_returned

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
@Test
public void given__root__when__children__then__children_returned() throws Exception {
    ASFGitSCMFileSystem fs = new ASFGitSCMFileSystem(serverRootUrl + "/maven.git", new SCMHead("master"), null);
    SCMFile root = fs.getRoot();
    Iterable<SCMFile> children = root.children();
    Set<String> names = new TreeSet<>();
    for (SCMFile f : children) {
        names.add(f.getName());
    }
    assertThat(names, containsInAnyOrder(
            ".gitattributes",
            ".gitignore",
            "Jenkinsfile",
            "LICENSE",
            "NOTICE",
            "README.md",
            "apache-maven",
            "deploySite.sh",
            "doap_Maven.rdf",
            "maven-artifact",
            "maven-builder-support",
            "maven-compat",
            "maven-core",
            "maven-embedder",
            "maven-model-builder",
            "maven-model",
            "maven-plugin-api",
            "maven-repository-metadata",
            "maven-resolver-provider",
            "maven-settings-builder",
            "maven-settings",
            "maven-slf4j-provider",
            "pom.xml",
            "src"
    ));
}
 
开发者ID:stephenc,项目名称:asf-gitpubsub-jenkins-plugin,代码行数:37,代码来源:ASFGitSCMFileTest.java


示例20: given__child__when__children__then__children_returned

import jenkins.scm.api.SCMHead; //导入依赖的package包/类
@Test
public void given__child__when__children__then__children_returned() throws Exception {
    ASFGitSCMFileSystem fs = new ASFGitSCMFileSystem(serverRootUrl + "/maven.git", new SCMHead("master"), null);
    SCMFile root = fs.getRoot().child("maven-settings");
    Iterable<SCMFile> children = root.children();
    Set<String> names = new TreeSet<>();
    for (SCMFile f : children) {
        names.add(f.getName());
    }
    assertThat(names, containsInAnyOrder(
            "pom.xml",
            "src"
    ));
}
 
开发者ID:stephenc,项目名称:asf-gitpubsub-jenkins-plugin,代码行数:15,代码来源:ASFGitSCMFileTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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