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


Java JobWithDetails.getNextBuildNumber方法代码示例

本文整理汇总了Java中com.offbytwo.jenkins.model.JobWithDetails.getNextBuildNumber方法的典型用法代码示例。如果您正苦于以下问题:Java JobWithDetails.getNextBuildNumber方法的具体用法?Java JobWithDetails.getNextBuildNumber怎么用?Java JobWithDetails.getNextBuildNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.offbytwo.jenkins.model.JobWithDetails的用法示例。


在下文中一共展示了JobWithDetails.getNextBuildNumber方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: waitForBuildToComplete

import com.offbytwo.jenkins.model.JobWithDetails; //导入方法依赖的package包/类
/**
 * Wait for the build to be queued and complete
 *
 * @param jenkins          Jenkins server instance
 * @param expectedBuildNbr the build number we're are expecting
 * @param timeOut          the maximum time in millisecond we are waiting
 * @throws InterruptedException the build was interrupted
 * @throws TimeoutException     we exeeded the timeout period.
 * @throws IOException          an unexpected error occurred while communicating with Jenkins
 */
private void waitForBuildToComplete(JenkinsServer jenkins, int expectedBuildNbr, long timeOut) throws InterruptedException, TimeoutException, IOException {
    boolean buildCompleted = false;
    Long timeoutCounter = 0L;
    while (!buildCompleted) {
        Thread.sleep(2000);
        timeoutCounter = timeoutCounter + 2000L;
        if (timeoutCounter > timeOut) {
            throw new TimeoutException("The job did not complete in the expected time");
        }
        //When the build is in the queue, the nextbuild number didn't change.
        //When it changed, It might still be running.
        JobWithDetails wrkJobData = jenkins.getJob(JENKINS_JOB_NAME);
        int newNextNbr = wrkJobData.getNextBuildNumber();
        log.info("New Next Nbr:" + newNextNbr);
        if (expectedBuildNbr != newNextNbr) {
            log.info("The expected build is there");
            boolean isBuilding = wrkJobData.getLastBuild().details().isBuilding();
            if (!isBuilding) {
                buildCompleted = true;
            }
        }
    }
}
 
开发者ID:jenkinsci,项目名称:gogs-webhook-plugin,代码行数:34,代码来源:GogsWebHook_IT.java

示例2: testStopBuildById

import com.offbytwo.jenkins.model.JobWithDetails; //导入方法依赖的package包/类
@Test
public void testStopBuildById() throws IOException, InterruptedException {
    
    String jobName = "testing-jenkins-api";
    String parameterNameForJob = "ParamForTesting";
    final ImmutableMap<String, String> params = ImmutableMap.of(parameterNameForJob, "master");
    
    BuildVerifier buildVerifier = CollectorApi.getJenkinsVerifier();
    JenkinsServer jenkninsServer = CollectorApi.getJenkinsServer();
    JobWithDetails job = jenkninsServer.getJob(jobName);
    int nextBuildNumber = job.getNextBuildNumber();
    job.build(params);
    Thread.sleep(5000);
    boolean stopBuildResult =
            ((JenkinsVerifier) buildVerifier).stop(jobName, Integer.toString(nextBuildNumber));
    Assert.assertEquals(true, stopBuildResult);
}
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:18,代码来源:TestJenkinsVerifier.java


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