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

Java SCMRevision类代码示例

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

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



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

示例1: GiteaSCMFileSystem

import jenkins.scm.api.SCMRevision; //导入依赖的package包/类
protected GiteaSCMFileSystem(GiteaConnection connection, GiteaRepository repo, String ref,
                             @CheckForNull SCMRevision rev) throws IOException {
    super(rev);
    this.connection = connection;
    this.repo = repo;
    if (rev != null) {
        if (rev.getHead() instanceof PullRequestSCMHead) {
            this.ref = ((PullRequestSCMRevision) rev).getOrigin().getHash();
        } else if (rev instanceof BranchSCMRevision) {
            this.ref = ((BranchSCMRevision) rev).getHash();
        } else {
            this.ref = ref;
        }
    } else {
        this.ref = ref;
    }
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:18,代码来源:GiteaSCMFileSystem.java


示例2: doRun

import jenkins.scm.api.SCMRevision; //导入依赖的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


示例3: build

import jenkins.scm.api.SCMRevision; //导入依赖的package包/类
@Override
public SCMFileSystem build(@NonNull Item owner, @NonNull SCM scm, @CheckForNull SCMRevision rev) throws IOException, InterruptedException {
	if (scm == null || !(scm instanceof PerforceScm)) {
		return null;
	}
	PerforceScm p4scm = (PerforceScm) scm;

	if (rev != null && !(rev instanceof P4Revision)) {
		return null;
	}
	P4Revision p4rev = (P4Revision) rev;

	try {
		return new P4SCMFileSystem(owner, p4scm, p4rev);
	} catch (Exception e) {
		throw new IOException(e);
	}
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:19,代码来源:P4SCMFileSystem.java


示例4: build

import jenkins.scm.api.SCMRevision; //导入依赖的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


示例5: headsFor

import jenkins.scm.api.SCMRevision; //导入依赖的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


示例6: headsFor

import jenkins.scm.api.SCMRevision; //导入依赖的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


示例7: GiteaSCMBuilder

import jenkins.scm.api.SCMRevision; //导入依赖的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


示例8: retrieve

import jenkins.scm.api.SCMRevision; //导入依赖的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


示例9: ForkPullRequestDiscoveryTrait

import jenkins.scm.api.SCMRevision; //导入依赖的package包/类
/**
 * Constructor for stapler.
 *
 * @param strategyId the strategy id.
 * @param trust      the authority to use.
 */
@DataBoundConstructor
public ForkPullRequestDiscoveryTrait(int strategyId,
                                     @NonNull SCMHeadAuthority<? super GiteaSCMSourceRequest, ? extends
                                             ChangeRequestSCMHead2, ? extends SCMRevision> trust) {
    this.strategyId = strategyId;
    this.trust = trust;
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:14,代码来源:ForkPullRequestDiscoveryTrait.java


示例10: ASFGitSCMFileSystem

import jenkins.scm.api.SCMRevision; //导入依赖的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


示例11: smokeTestGetRevisions

import jenkins.scm.api.SCMRevision; //导入依赖的package包/类
@Test
public void smokeTestGetRevisions() throws Exception {
    Iterable<SCMRevision> revisions = new ASFGitSCMFileSystem.TelescopeImpl()
            .getRevisions(serverRootUrl+"/maven.git", null, EnumSet.allOf(
                    GitSCMTelescope.ReferenceType.class));
    GitTagSCMRevision annotatedTagR = null;
    GitTagSCMRevision lightweightTagR = null;
    AbstractGitSCMSource.SCMRevisionImpl masterBranchR = null;
    for (SCMRevision r: revisions) {
        if (r instanceof AbstractGitSCMSource.SCMRevisionImpl && r.getHead().getName().equals("master")) {
            masterBranchR = (AbstractGitSCMSource.SCMRevisionImpl) r;
        } else if (r instanceof GitTagSCMRevision && r.getHead().getName().equals("lightweight-tag")) {
            lightweightTagR = (GitTagSCMRevision) r;
        } else if (r instanceof GitTagSCMRevision && r.getHead().getName().equals("annotated-tag")) {
            annotatedTagR = (GitTagSCMRevision) r;
        }
        if (masterBranchR != null && annotatedTagR != null && lightweightTagR != null) {
            break;
        }
    }
    assertThat(masterBranchR.getHash(), is("f5f76c70e1828a7e6c6267fc4bc53abc35c19ce7"));
    assertThat(lightweightTagR.getHash(), is("5919b7450d2e01f079e930d92df7910af39d489a"));
    assertThat(annotatedTagR.getHash(), is("61a8c2048bec05c0748b143e3bfd54f97d1a1423"));
    assertThat(((TagSCMHead)lightweightTagR.getHead()).getTimestamp(),
            timestamp("Thu, 26 Oct 2017 08:30:12 +0000")
    );
    assertThat(((TagSCMHead)annotatedTagR.getHead()).getTimestamp(),
            timestamp("Mon, 20 Nov 2017 11:38:47 +0000")
    );
}
 
开发者ID:stephenc,项目名称:asf-gitpubsub-jenkins-plugin,代码行数:31,代码来源:ASFGitSCMFileSystemTest.java


示例12: given__branch__when__getRevision__then__branch_returned

import jenkins.scm.api.SCMRevision; //导入依赖的package包/类
@Test
public void given__branch__when__getRevision__then__branch_returned() throws Exception {
    SCMRevision masterR = new ASFGitSCMFileSystem.TelescopeImpl()
            .getRevision(serverRootUrl+"/maven.git", null, "refs/heads/master");
    assertThat(masterR, instanceOf(AbstractGitSCMSource.SCMRevisionImpl.class));
    AbstractGitSCMSource.SCMRevisionImpl masterBranchR = (AbstractGitSCMSource.SCMRevisionImpl) masterR;
    assertThat(masterBranchR.getHash(), is("f5f76c70e1828a7e6c6267fc4bc53abc35c19ce7"));
}
 
开发者ID:stephenc,项目名称:asf-gitpubsub-jenkins-plugin,代码行数:9,代码来源:ASFGitSCMFileSystemTest.java


示例13: given__lightweight_tag__when__getRevision__then__tag_returned

import jenkins.scm.api.SCMRevision; //导入依赖的package包/类
@Test
public void given__lightweight_tag__when__getRevision__then__tag_returned() throws Exception {
    SCMRevision lightweightR = new ASFGitSCMFileSystem.TelescopeImpl()
            .getRevision(serverRootUrl+"/maven.git", null, "refs/tags/lightweight-tag");
    assertThat(lightweightR, instanceOf(GitTagSCMRevision.class));
    GitTagSCMRevision lightweightTagR = (GitTagSCMRevision) lightweightR;
    assertThat(lightweightTagR.getHash(), is("5919b7450d2e01f079e930d92df7910af39d489a"));
    assertThat(((TagSCMHead)lightweightTagR.getHead()).getTimestamp(),
            timestamp("Thu, 26 Oct 2017 08:30:12 +0000")
    );
}
 
开发者ID:stephenc,项目名称:asf-gitpubsub-jenkins-plugin,代码行数:12,代码来源:ASFGitSCMFileSystemTest.java


示例14: given__annotated_tag__when__getRevision__then__tag_returned

import jenkins.scm.api.SCMRevision; //导入依赖的package包/类
@Test
public void given__annotated_tag__when__getRevision__then__tag_returned() throws Exception {
    SCMRevision annotatedR = new ASFGitSCMFileSystem.TelescopeImpl()
            .getRevision(serverRootUrl+"/maven.git", null, "refs/tags/annotated-tag");
    assertThat(annotatedR, instanceOf(GitTagSCMRevision.class));
    GitTagSCMRevision annotatedTagR = (GitTagSCMRevision) annotatedR;
    assertThat(annotatedTagR.getHash(), is("61a8c2048bec05c0748b143e3bfd54f97d1a1423"));
    assertThat(((TagSCMHead)annotatedTagR.getHead()).getTimestamp(),
            timestamp("Mon, 20 Nov 2017 11:38:47 +0000")
    );
}
 
开发者ID:stephenc,项目名称:asf-gitpubsub-jenkins-plugin,代码行数:12,代码来源:ASFGitSCMFileSystemTest.java


示例15: create

import jenkins.scm.api.SCMRevision; //导入依赖的package包/类
static GitLabSCMProbe create(GitLabSCMSource source, SCMHead head, SCMRevision revision) {
    if (!SCMRevisionImpl.class.isInstance(revision)) {
        return create(source, head, new SCMRevisionImpl(head, REVISION_HEAD));
    }

    if (head instanceof GitLabSCMMergeRequestHead) {
        return create(source, ((GitLabSCMMergeRequestHead) head).getSource(), revision);
    }

    int projectId = (head instanceof GitLabSCMHead) ? ((GitLabSCMHead) head).getProjectId() : source.getProjectId();
    return new GitLabSCMProbe(source.getSourceSettings().getConnectionName(), projectId, head.getName(), ((SCMRevisionImpl) revision).getHash());
}
 
开发者ID:Argelbargel,项目名称:gitlab-branch-source-plugin,代码行数:13,代码来源:GitLabSCMProbe.java


示例16: retrieve

import jenkins.scm.api.SCMRevision; //导入依赖的package包/类
@CheckForNull
SCMRevision retrieve(@Nonnull SCMHead head, @Nonnull TaskListener listener) throws IOException, InterruptedException {
    log(listener, Messages.GitLabSCMSource_retrievingRevision(head.getName()));
    try {
        return new SCMRevisionImpl(head, retrieveRevision(head));
    } catch (NoSuchElementException e) {
        return null;
    }
}
 
开发者ID:Argelbargel,项目名称:gitlab-branch-source-plugin,代码行数:10,代码来源:SourceHeads.java


示例17: createProbe

import jenkins.scm.api.SCMRevision; //导入依赖的package包/类
@Nonnull
@Override
protected SCMProbe createProbe(@Nonnull SCMHead head, @CheckForNull SCMRevision revision) {
    return GitLabSCMProbe.create(this, head, revision);
}
 
开发者ID:Argelbargel,项目名称:gitlab-branch-source-plugin,代码行数:6,代码来源:GitLabSCMSource.java


示例18: retrieve

import jenkins.scm.api.SCMRevision; //导入依赖的package包/类
@Nonnull
List<Action> retrieve(@Nonnull SCMRevision revision, @CheckForNull SCMHeadEvent event, @Nonnull TaskListener listener) throws IOException, InterruptedException {
    if (revision instanceof SCMRevisionImpl) {
        return retrieve((SCMRevisionImpl) revision, event, listener);
    }

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


示例19: checkout

import jenkins.scm.api.SCMRevision; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean checkout(AbstractBuild build, Launcher launcher,
    BuildListener listener, File changelogFile)
    throws IOException, InterruptedException {
  final FilePath workspace = _shareWorkspace(build.getBuiltOn());
  if (workspace != null) {
    listener.getLogger().println(
        Messages.AbstractBranchAwareProject_SharingWorkspace());
    checkState(isDelegate());
    // Instead of performing a full 'checkout', just have the
    // DelegateSCM attach the appropriate SCMRevisionAction.
    ((DelegateSCM) getScm()).parentSCMFromBuild(
        build, true /* attach SCMRevisionAction */);
    return true;
  }

  boolean result = super.checkout(build, launcher, listener, changelogFile);

  // Attach an SCMRevisionAction to this build, so that if/when the nested
  // build checks out with the DelegateSCM it knows what revision to
  // checkout.
  // NOTE: If we are a delegate then DelegateSCM adds the appropriate
  // SCMRevisionAction for us during the above checkout call.
  if (build.getAction(SCMRevisionAction.class) == null) {
    final SCMHead head = getBranch().getHead();
    final SCMSource source = getSource();
    final SCMRevision revision = source.fetch(head, listener);
    if (revision == null) {
      throw new IllegalStateException("Revision action without revision");
    }
    build.addAction(new SCMRevisionAction(revision));
  }
  return result;
}
 
开发者ID:jenkinsci,项目名称:yaml-project-plugin,代码行数:36,代码来源:AbstractBranchAwareProject.java


示例20: parentSCMFromBuild

import jenkins.scm.api.SCMRevision; //导入依赖的package包/类
/**
 * Fetch a changeset-bound SCM for actions like checking out code.
 * <p>
 * NOTE: Modeled after Literate Build plugin's "checkout" methods
 *
 * @param build The active build for which we need an actual {@link SCM}
 * @param attachAction Whether to attach the SCMRevisionAction from the
 *                     parent build to this build.
 * @return An {@link SCM} derived from our parent {@code T} project, but
 * additionally bound to the changeset at which our originating build ran.
 */
SCM parentSCMFromBuild(AbstractBuild build, boolean attachAction) {
  T parentProject = getParentProject(build.getProject());

  // Using actions is unreliable if there are nested projects through
  // which we must see (e.g. Matrix), or if we want am abstraction
  // where children are free to trigger other children, all tracked by a
  // single parent build (no way to easily attach "parent" actions).
  final AbstractBuild parentBuild = getParentBuild(parentProject, build);

  // The parent project must attach this action with its revision state
  // prior to delegation for this to know what changeset at which to build.
  final SCMRevisionAction hashAction =
      parentBuild.getAction(SCMRevisionAction.class);
  checkState(hashAction != null, Messages.DelegateSCM_NoRevision());
  if (attachAction) {
    build.addAction(hashAction);
  }

  // SCMSource is a sort of SCM-factory.  Get it for our
  // AbstractBranchAwareProject and use it to construct an SCM at the
  // appropriate revision.
  final SCMSource source = parentProject.getSource();
  final SCMRevision revisionHash = hashAction.getRevision();
  final SCMHead head = revisionHash.getHead();
  return source.build(head, revisionHash);
}
 
开发者ID:jenkinsci,项目名称:yaml-project-plugin,代码行数:38,代码来源:DelegateSCM.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java InstanceInfo类代码示例发布时间:2022-05-22
下一篇:
Java FloatActionButton类代码示例发布时间: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