本文整理汇总了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;
}
}
}
}
示例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);
}