当前位置: 首页>>代码示例>>Java>>正文


Java SCMRevision类代码示例

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


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


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