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

Java Revision类代码示例

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

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



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

示例1: decorateRevisionToBuild

import hudson.plugins.git.Revision; //导入依赖的package包/类
@Override
public Revision decorateRevisionToBuild(GitSCM scm, Run<?, ?> build, GitClient git, TaskListener listener, Revision marked, Revision rev) throws IOException, InterruptedException, GitException {
    listener.getLogger().println("Merging " + targetBranch.getName() + " commit " + targetBranch.getRevision().getHash() + " into merge-request head commit " + rev.getSha1String());
    checkout(scm, build, git, listener, rev);
    try {
        git.setAuthor("Jenkins", /* could parse out of JenkinsLocationConfiguration.get().getAdminAddress() but seems overkill */"[email protected]");
        git.setCommitter("Jenkins", "[email protected]");
        MergeCommand cmd = git.merge().setRevisionToMerge(ObjectId.fromString(targetBranch.getRevision().getHash()));
        for (GitSCMExtension ext : scm.getExtensions()) {
            // By default we do a regular merge, allowing it to fast-forward.
            ext.decorateMergeCommand(scm, build, git, listener, cmd);
        }
        cmd.execute();
    } catch (GitException e) {
        // Try to revert merge conflict markers.
        checkout(scm, build, git, listener, rev);
        throw e;
    }
    build.addAction(new MergeRecord(targetBranch.getRefSpec().destinationRef(targetBranch.getName()), targetBranch.getRevision().getHash())); // does not seem to be used, but just in case
    ObjectId mergeRev = git.revParse(Constants.HEAD);
    listener.getLogger().println("Merge succeeded, producing " + mergeRev.name());
    return new Revision(mergeRev, rev.getBranches()); // note that this ensures Build.revision != Build.marked
}
 
开发者ID:Argelbargel,项目名称:gitlab-branch-source-plugin,代码行数:24,代码来源:GitLabSCMMergeRequestHead.java


示例2: getCandidateRevisions

import hudson.plugins.git.Revision; //导入依赖的package包/类
/**
 * Get failing build revision if this is a deflake build, otherwise use the default build chooser
 */
@Override
public Collection<Revision> getCandidateRevisions(boolean isPollCall, String singleBranch,
    GitClient git,
    TaskListener listener, BuildData buildData,
    BuildChooserContext context)
    throws GitException, IOException, InterruptedException {

  AbstractBuild build = context.actOnBuild(new GetBuild());
  // Not sure why it cannot be inferred and we have to put cast here
  DeflakeCause cause = (DeflakeCause) build.getCause(DeflakeCause.class);

  if (cause != null) {
    BuildData gitBuildData = gitSCM.getBuildData(cause.getUpstreamRun(), true);
    Revision revision = gitBuildData.getLastBuiltRevision();
    if (revision != null) {
      return Collections.singletonList(revision);
    }
  }

  // If it is not a deflake run, then use the default git checkout strategy
  defaultBuildChooser.gitSCM = this.gitSCM;
  return defaultBuildChooser
      .getCandidateRevisions(isPollCall, singleBranch, git, listener, buildData, context);
}
 
开发者ID:jenkinsci,项目名称:flaky-test-handler-plugin,代码行数:28,代码来源:DeflakeGitBuildChooser.java


示例3: SingleTestFlakyStatsWithRevision

import hudson.plugins.git.Revision; //导入依赖的package包/类
/**
 * Construct a SingleTestFlakyStatsWithRevision object with {@link SingleTestFlakyStats} and
 * build information.
 *
 * @param stats Embedded {@link SingleTestFlakyStats} object
 * @param build The {@link hudson.model.AbstractBuild} object to get SCM information from.
 */
public SingleTestFlakyStatsWithRevision(SingleTestFlakyStats stats, AbstractBuild build) {
  this.stats = stats;
  revision = Integer.toString(build.getNumber());

  SCM scm = build.getProject().getScm();
  if (scm != null && scm instanceof GitSCM) {
    GitSCM gitSCM = (GitSCM) scm;
    BuildData buildData = gitSCM.getBuildData(build);
    if (buildData != null) {
      Revision gitRevision = buildData.getLastBuiltRevision();
      if (gitRevision != null) {
        revision = gitRevision.getSha1String();
      }
    }
  }
}
 
开发者ID:jenkinsci,项目名称:flaky-test-handler-plugin,代码行数:24,代码来源:HistoryAggregatedFlakyTestResultAction.java


示例4: getBuildRevision

import hudson.plugins.git.Revision; //导入依赖的package包/类
private static String getBuildRevision(Run<?, ?> build) {
    GitLabWebHookCause cause = build.getCause(GitLabWebHookCause.class);
    if (cause != null) {
        return cause.getData().getLastCommit();
    }

    BuildData action = build.getAction(BuildData.class);
    if (action == null) {
        throw new IllegalStateException("No (git-plugin) BuildData associated to current build");
    }
    Revision lastBuiltRevision = action.getLastBuiltRevision();

    if (lastBuiltRevision == null) {
        throw new IllegalStateException("Last build has no associated commit");
    }

    return action.getLastBuild(lastBuiltRevision.getSha1()).getMarked().getSha1String();
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:19,代码来源:CommitStatusUpdater.java


示例5: createBuildData

import hudson.plugins.git.Revision; //导入依赖的package包/类
private BuildData createBuildData(String sha) {
  
  BuildData buildData = mock(BuildData.class);
  Revision revision = mock(Revision.class);
  when(revision.getSha1String()).thenReturn(sha);
  when(buildData.getLastBuiltRevision()).thenReturn(revision);

  Build gitBuild = mock(Build.class);
  when(gitBuild.getMarked()).thenReturn(revision);
  when(buildData.getLastBuild(any(ObjectId.class))).thenReturn(gitBuild);
  when(gitBuild.getRevision()).thenReturn(revision);
  when(gitBuild.isFor(sha)).thenReturn(true);
  buildData.lastBuild = gitBuild;

  return buildData;
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:17,代码来源:BuildUtilTest.java


示例6: integrateAsGitPluginExt

import hudson.plugins.git.Revision; //导入依赖的package包/类
@Override
public void integrateAsGitPluginExt(GitSCM scm, Run<?, ?> build, GitClient git, TaskListener listener, Revision marked, Revision rev, GitBridge gitbridge) throws NothingToDoException, IntegrationFailedException, IOException, InterruptedException {


    String expandedRepoName;
    try {
        expandedRepoName = gitbridge.getExpandedRepository(build.getEnvironment(listener));
    } catch (IOException | InterruptedException ex) {
        expandedRepoName = gitbridge.getRepoName();
    }

    if (!PretestedIntegrationGitUtils.isRelevant(rev, expandedRepoName)) {
        throw new NothingToDoException("No revision matches configuration in 'Integration repository'");
    }

    Branch triggerBranch = rev.getBranches().iterator().next();
    String expandedIntegrationBranch = gitbridge.getExpandedIntegrationBranch(build.getEnvironment(listener));
    doTheIntegration((Run) build, listener, gitbridge, triggerBranch.getSHA1(), git, expandedIntegrationBranch, triggerBranch);
}
 
开发者ID:Praqma,项目名称:pretested-integration-plugin,代码行数:20,代码来源:AccumulatedCommitStrategy.java


示例7: checkout

import hudson.plugins.git.Revision; //导入依赖的package包/类
private void checkout(GitSCM scm, Run<?, ?> build, GitClient git, TaskListener listener, Revision rev) throws InterruptedException, IOException, GitException {
    CheckoutCommand checkoutCommand = git.checkout().ref(rev.getSha1String());
    for (GitSCMExtension ext : scm.getExtensions()) {
        ext.decorateCheckoutCommand(scm, build, git, listener, checkoutCommand);
    }
    checkoutCommand.execute();
}
 
开发者ID:Argelbargel,项目名称:gitlab-branch-source-plugin,代码行数:8,代码来源:GitLabSCMMergeRequestHead.java


示例8: getGitSourceCommit

import hudson.plugins.git.Revision; //导入依赖的package包/类
private String getGitSourceCommit() {
    // depend on git plugin
    for (BuildData data : getJenkinsBuild().getActions(BuildData.class)) {
        Revision revision = data.getLastBuiltRevision();
        if (revision != null) {
            return revision.getSha1String();
        }
    }

    return null;
}
 
开发者ID:Microsoft,项目名称:vsts-jenkins-build-integration-sample,代码行数:12,代码来源:TfsBuildFacadeImpl.java


示例9: mockBuild

import hudson.plugins.git.Revision; //导入依赖的package包/类
private AbstractBuild mockBuild(String gitLabConnection, Result result, String... remoteUrls) {
    AbstractBuild build = mock(AbstractBuild.class);
    List<BuildData> buildDatas = new ArrayList<>();
    BuildData buildData = mock(BuildData.class);
    Revision revision = mock(Revision.class);
    when(revision.getSha1String()).thenReturn(SHA1);
    when(buildData.getLastBuiltRevision()).thenReturn(revision);
    when(buildData.getRemoteUrls()).thenReturn(new HashSet<>(Arrays.asList(remoteUrls)));
    Build gitBuild = mock(Build.class);
    when(gitBuild.getMarked()).thenReturn(revision);
    when(buildData.getLastBuild(any(ObjectId.class))).thenReturn(gitBuild);
    buildDatas.add(buildData);
    when(build.getActions(BuildData.class)).thenReturn(buildDatas);
    when(build.getAction(BuildData.class)).thenReturn(buildData);
    when(build.getResult()).thenReturn(result);
    when(build.getUrl()).thenReturn(BUILD_URL);
    AbstractProject<?, ?> project = mock(AbstractProject.class);
    when(project.getProperty(GitLabConnectionProperty.class)).thenReturn(new GitLabConnectionProperty(gitLabConnection));
    when(build.getProject()).thenReturn(project);
    EnvVars environment = mock(EnvVars.class);
    when(environment.expand(anyString())).thenAnswer(new Answer<String>() {
        @Override
        public String answer(InvocationOnMock invocation) throws Throwable {
            return (String) invocation.getArguments()[0];
        }
    });
    try {
        when(build.getEnvironment(any(TaskListener.class))).thenReturn(environment);
    } catch (IOException | InterruptedException e) {
        throw new RuntimeException(e);
    }
    return build;
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:34,代码来源:GitLabCommitStatusPublisherTest.java


示例10: testShouldBeCommited

import hudson.plugins.git.Revision; //导入依赖的package包/类
@Test
public void testShouldBeCommited() throws Exception {
    DummySCM scm = new DummySCM(null);
    FreeStyleBuild build = mock(FreeStyleBuild.class);
    when(build.getResult()).thenReturn(Result.SUCCESS);
    Launcher launcher = mock(Launcher.class);

    BuildData gitBuildData = mock(BuildData.class);
    Build lastBuild = mock(Build.class);
    Revision rev = mock(Revision.class);
    Branch gitBranchData = mock(Branch.class);

    gitBuildData.lastBuild = lastBuild;
    lastBuild.revision = rev;

    when(build.getAction(BuildData.class)).thenReturn(gitBuildData);

    List<Branch> branches = new ArrayList<>();
    branches.add(gitBranchData);
    when(gitBuildData.lastBuild.revision.getBranches()).thenReturn(branches);
    when(gitBranchData.getName()).thenReturn("origin/ready/f1");

    OutputStream out = new ByteArrayOutputStream();
    BuildListener listener = new StreamBuildListener(out);

    assertFalse(scm.isCommited());
    scm.handlePostBuild(build, launcher, listener);
    assertTrue(scm.isCommited());
}
 
开发者ID:Praqma,项目名称:pretested-integration-plugin,代码行数:30,代码来源:AbstractSCMBridgeTest.java


示例11: testSetupSubmoduleUrls

import hudson.plugins.git.Revision; //导入依赖的package包/类
public void testSetupSubmoduleUrls() throws Exception {
    System.out.println("setupSubmoduleUrls");
    Revision rev = null;
    TaskListener listener = null;
    GitClient instance = gitClient;
    instance.setupSubmoduleUrls(rev, listener);
    fail("The test case is a prototype.");
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:9,代码来源:GitClientTest.java


示例12: testShowRevisionThrowsGitException

import hudson.plugins.git.Revision; //导入依赖的package包/类
@Test
@Deprecated
public void testShowRevisionThrowsGitException() throws Exception {
    File trackedFile = commitTrackedFile();
    thrown.expect(GitException.class);
    git.showRevision(new Revision(gitClientCommit));
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:8,代码来源:LegacyCompatibleGitAPIImplTest.java


示例13: testShowRevisionTrackedFile

import hudson.plugins.git.Revision; //导入依赖的package包/类
@Test
@Deprecated
public void testShowRevisionTrackedFile() throws Exception {
    File trackedFile = commitTrackedFile();
    ObjectId head = git.getHeadRev(repo.getPath(), "master");
    List<String> revisions = git.showRevision(new Revision(head));
    assertEquals("commit " + head.name(), revisions.get(0));
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:9,代码来源:LegacyCompatibleGitAPIImplTest.java


示例14: fromPull

import hudson.plugins.git.Revision; //导入依赖的package包/类
public static String fromPull(BuildData buildData, Optional<String> organization) {
    Set<String> remoteUrls = buildData.getRemoteUrls();

    checkArgument(!remoteUrls.isEmpty(), "buildData does not contain any remote URLs");

    Revision lastBuiltRevision = buildData.getLastBuiltRevision();
    Collection<hudson.plugins.git.Branch> scmBranches = lastBuiltRevision.getBranches();

    checkArgument(!scmBranches.isEmpty(), "buildData last revision does not contain any branches");

    String firstRemoteUrl = remoteUrls.iterator().next();
    Repository repository = new Repository(firstRemoteUrl);

    hudson.plugins.git.Branch firstScmBranch = scmBranches.iterator().next();
    Branch branch = new Branch(firstScmBranch);

    return generateRemoteImageName(organization, repository, branch);
}
 
开发者ID:spoonapps,项目名称:jenkins,代码行数:19,代码来源:RemoteImageGenerator.java


示例15: mockBuildWithLibrary

import hudson.plugins.git.Revision; //导入依赖的package包/类
private AbstractBuild mockBuildWithLibrary(String gitLabConnection, Result result, String... remoteUrls) {
    AbstractBuild build = mock(AbstractBuild.class);
    List<BuildData> buildDatas = new ArrayList<>();
    BuildData buildData = mock(BuildData.class);
    SCMRevisionAction scmRevisionAction = mock(SCMRevisionAction.class);
    AbstractGitSCMSource.SCMRevisionImpl revisionImpl = mock(AbstractGitSCMSource.SCMRevisionImpl.class);
    
    when(build.getAction(SCMRevisionAction.class)).thenReturn(scmRevisionAction);
    when(scmRevisionAction.getRevision()).thenReturn(revisionImpl);
    when(revisionImpl.getHash()).thenReturn(SHA1);
    
    Revision revision = mock(Revision.class);
    when(revision.getSha1String()).thenReturn(SHA1);
    when(buildData.getLastBuiltRevision()).thenReturn(revision);
    when(buildData.getRemoteUrls()).thenReturn(new HashSet<>(Arrays.asList(remoteUrls)));

    Build gitBuild = mock(Build.class);

    when(gitBuild.getMarked()).thenReturn(revision);
    when(gitBuild.getSHA1()).thenReturn(ObjectId.fromString(SHA1));
    when(buildData.getLastBuild(any(ObjectId.class))).thenReturn(gitBuild);
    Map<String, Build> buildsByBranchName = new HashMap<>();
    buildsByBranchName.put("develop", gitBuild);
    when(buildData.getBuildsByBranchName()).thenReturn(buildsByBranchName);
    buildDatas.add(buildData);
    
    //Second build data (@librabry)
    BuildData buildDataLib = mock(BuildData.class);
    Revision revisionLib = mock(Revision.class);
    when(revisionLib.getSha1String()).thenReturn("SHALIB");
    when(buildDataLib.getLastBuiltRevision()).thenReturn(revisionLib);
    Build gitBuildLib = mock(Build.class);
    when(gitBuildLib.getMarked()).thenReturn(revisionLib);
    when(buildDataLib.getLastBuild(any(ObjectId.class))).thenReturn(gitBuildLib);
    buildDatas.add(buildDataLib);
    
    when(build.getActions(BuildData.class)).thenReturn(buildDatas);
    when(build.getResult()).thenReturn(result);
    when(build.getUrl()).thenReturn(BUILD_URL);

    AbstractProject<?, ?> project = mock(AbstractProject.class);
    when(project.getProperty(GitLabConnectionProperty.class)).thenReturn(new GitLabConnectionProperty(gitLabConnection));
    when(build.getProject()).thenReturn(project);
    EnvVars environment = mock(EnvVars.class);
    when(environment.expand(anyString())).thenAnswer(new Answer<String>() {
        @Override
        public String answer(InvocationOnMock invocation) throws Throwable {
            return (String) invocation.getArguments()[0];
        }
    });
    try {
        when(build.getEnvironment(any(TaskListener.class))).thenReturn(environment);
    } catch (IOException | InterruptedException e) {
        throw new RuntimeException(e);
    }
    return build;
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:58,代码来源:GitLabCommitStatusPublisherTest.java


示例16: isRelevant

import hudson.plugins.git.Revision; //导入依赖的package包/类
public static boolean isRelevant(Revision r, String repoName) {
    Branch br = r.getBranches().iterator().next();

    return br.getName().startsWith(repoName + "/");
}
 
开发者ID:Praqma,项目名称:pretested-integration-plugin,代码行数:6,代码来源:PretestedIntegrationGitUtils.java


示例17: setupSubmoduleUrls

import hudson.plugins.git.Revision; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * Set up submodule URLs so that they correspond to the remote pertaining to
 * the revision that has been checked out.
 */
public void setupSubmoduleUrls( Revision rev, TaskListener listener ) throws GitException, InterruptedException {
    String remote = null;

    // try to locate the remote repository from where this commit came from
    // (by using the heuristics that the branch name, if available, contains the remote name)
    // if we can figure out the remote, the other setupSubmoduleUrls method
    // look at its URL, and if it's a non-bare repository, we attempt to retrieve modules
    // from this checked out copy.
    //
    // the idea is that you have something like tree-structured repositories: at the root you have corporate central repositories that you
    // ultimately push to, which all .gitmodules point to, then you have intermediate team local repository,
    // which is assumed to be a non-bare repository (say, a checked out copy on a shared server accessed via SSH)
    //
    // the abovementioned behaviour of the Git plugin makes it pick up submodules from this team local repository,
    // not the corporate central.
    //
    // (Kohsuke: I have a bit of hesitation/doubt about such a behaviour change triggered by seemingly indirect
    // evidence of whether the upstream is bare or not (not to mention the fact that you can't reliably
    // figure out if the repository is bare or not just from the URL), but that's what apparently has been implemented
    // and we care about the backward compatibility.)
    //
    // note that "figuring out which remote repository the commit came from" isn't a well-defined
    // question, and this is really a heuristics. The user might be telling us to build a specific SHA1.
    // or maybe someone pushed directly to the workspace and so it may not correspond to any remote branch.
    // so if we fail to figure this out, we back out and avoid being too clever. See JENKINS-10060 as an example
    // of where our trying to be too clever here is breaking stuff for people.
    for (Branch br : rev.getBranches()) {
        String b = br.getName();
        if (b != null) {
            int slash = b.indexOf('/');

            if ( slash != -1 )
                remote = getDefaultRemote( b.substring(0,slash) );
        }

        if (remote!=null)   break;
    }

    if (remote==null)
        remote = getDefaultRemote();

    if (remote!=null)
        setupSubmoduleUrls( remote, listener );
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:51,代码来源:CliGitAPIImpl.java


示例18: showRevision

import hudson.plugins.git.Revision; //导入依赖的package包/类
/** {@inheritDoc} */
@Deprecated
public List<String> showRevision(Revision r) throws GitException, InterruptedException {
    return showRevision(null, r.getSha1());
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:6,代码来源:LegacyCompatibleGitAPIImpl.java


示例19: showRevision

import hudson.plugins.git.Revision; //导入依赖的package包/类
/** {@inheritDoc} */
public List<String> showRevision(Revision r) throws GitException, InterruptedException {
    return getGitAPI().showRevision(r);
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:5,代码来源:RemoteGitImpl.java


示例20: setupSubmoduleUrls

import hudson.plugins.git.Revision; //导入依赖的package包/类
/** {@inheritDoc} */
public void setupSubmoduleUrls(Revision rev, TaskListener listener) throws GitException, InterruptedException {
    proxy.setupSubmoduleUrls(rev, listener);
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:5,代码来源:RemoteGitImpl.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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