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

Java JobWithDetails类代码示例

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

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



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

import com.offbytwo.jenkins.model.JobWithDetails; //导入依赖的package包/类
@Test
public void testCreateJob() throws Exception {
    final String sourceJob = "pr";
    final String jobName = "test-job-" + UUID.randomUUID().toString();

    String sourceXml = server.getJobXml(sourceJob);

    server.createJob(jobName, sourceXml);

    Map<String, Job> jobs = server.getJobs();
    assertTrue(jobs.containsKey(jobName));
    JobWithDetails thisJob = jobs.get(jobName).details();
    assertNotNull(thisJob);
    assertTrue(thisJob.getBuilds().size() == 0);
    thisJob.build(ImmutableMap.of("foo_param", "MUST_PROVIDE_VALUES_DEFAULTS_DONT_WORK"));

    // wait to see if the job finishes, but with a timeout
    Future<Void> future = executor.submit(new PerformPollingTest(server, jobName));

    // If this times out, either jenkins is slow or our test failed!
    // IME, usually takes about 10-15 seconds
    future.get(30, TimeUnit.SECONDS);

    Build b = server.getJobs().get(jobName).details().getLastSuccessfulBuild();
    assertTrue(b != null);
}
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:27,代码来源:JenkinsServerIntegration.java


示例3: 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


示例4: runJobIfFailing

import com.offbytwo.jenkins.model.JobWithDetails; //导入依赖的package包/类
public void runJobIfFailing(String test, JSONObject repository) throws Exception {
    String jobName = ConfigParser.parseConfigString(repository.getString("jobName"), test);

    JobWithDetails job = jenkins.getJob(jobName);
    if (job == null) {
        System.out.println("Job not yet created, skipping: [" + jobName + "]");
        return;
    }
    Build lastBuild = job.getLastBuild();
    if (lastBuild == null) {
        runJob(test, repository);
        return;
    }
    BuildResult lastResult = lastBuild.details().getResult();
    if (lastResult != null && lastResult.equals(BuildResult.FAILURE)) {
        runJob(test, repository);
    }
}
 
开发者ID:alianza-dev,项目名称:jenkins-test-job-generator,代码行数:19,代码来源:JenkinsHelper.java


示例5: assertJobExists

import com.offbytwo.jenkins.model.JobWithDetails; //导入依赖的package包/类
public static JobWithDetails assertJobExists(JenkinsServer jenkins, String jobName) {
    JobWithDetails job = tryFindJob(jenkins, jobName);
    if (job != null) {
        return job;
    }
    fail("No job found called `" + jobName + "` for jenkins at " + jenkins);
    return job;
}
 
开发者ID:fabric8io,项目名称:fabric8-devops,代码行数:9,代码来源:JenkinsAsserts.java


示例6: assertJobLastBuildIsSuccessful

import com.offbytwo.jenkins.model.JobWithDetails; //导入依赖的package包/类
public static void assertJobLastBuildIsSuccessful(long timeMillis, final JenkinsServer jenkins, final String jobName) throws Exception {
    Asserts.assertWaitFor(timeMillis, new Block() {
        @Override
        public void invoke() throws Exception {
            JobWithDetails job = assertJobExists(jenkins, jobName);
            Build lastBuild = job.getLastBuild();
            assertNotNull("No lastBuild for job `" + jobName + "`", lastBuild);
            System.out.println("Last build of `" + jobName + "` at " + lastBuild.getUrl());
            Build lastSuccessfulBuild = job.getLastSuccessfulBuild();
            assertNotNull("No lastSuccessfulBuild for job `" + jobName + "` at: " + lastBuild.getUrl(), lastSuccessfulBuild);
            assertEquals("Last successful build number was not the last build number: " + lastBuild.getUrl(), lastBuild.getNumber(), lastSuccessfulBuild.getNumber());
            System.out.println("Successful build of `" + jobName + "` at " + lastSuccessfulBuild.getUrl());
        }
    });
}
 
开发者ID:fabric8io,项目名称:fabric8-devops,代码行数:16,代码来源:JenkinsAsserts.java


示例7: tryFindJob

import com.offbytwo.jenkins.model.JobWithDetails; //导入依赖的package包/类
protected static JobWithDetails tryFindJob(JenkinsServer jenkins, String jobName) {
    for (int i = 0; i < 15; i++) {
        try {
            return jenkins.getJob(jobName);
        } catch (IOException e) {
            LOG.info("Caught: " + e, e);
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e1) {
                // ignore
            }
        }
    }
    return null;
}
 
开发者ID:fabric8io,项目名称:fabric8-devops,代码行数:16,代码来源:JenkinsAsserts.java


示例8: testBuild

import com.offbytwo.jenkins.model.JobWithDetails; //导入依赖的package包/类
@Test
public void testBuild() throws IOException {
    
	String jobName = "testing-jenkins-api";
    String parameterNameForJob = "ParamForTesting";
    final ImmutableMap<String, String> params = ImmutableMap.of(parameterNameForJob, "master");
    JenkinsServer jenkninsServer = CollectorApi.getJenkinsServer();
    JobWithDetails job = jenkninsServer.getJob(jobName);
    job.build(params);
}
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:11,代码来源:TestJenkinsVerifier.java


示例9: getJob

import com.offbytwo.jenkins.model.JobWithDetails; //导入依赖的package包/类
/**
 * Get a single Job from the server.
 * 
 * @return A single Job, null if not present
 * @throws IOException
 */
public JobWithDetails getJob(String jobName) throws IOException {
	try {
		JobWithDetails job = client.get("/job/" + encode(jobName),
				JobWithDetails.class);
		// JobWithDetails job = client.get("/job/" + jobName, JobWithDetails.class);
		job.setClient(client);

		return job;
	} catch (HttpResponseException e) {
		if (e.getStatusCode() == 404) {
			return null;
		}
		throw e;
	}

}
 
开发者ID:baloise,项目名称:dashboard-plus,代码行数:23,代码来源:JenkinsServer.java


示例10: assertJob

import com.offbytwo.jenkins.model.JobWithDetails; //导入依赖的package包/类
public static JobWithDetails assertJob(String projectName) throws URISyntaxException, IOException {
    JenkinsServer jenkins = createJenkinsServer();
    JobWithDetails job = jenkins.getJob(projectName);
    assertThat(job).describedAs("No Jenkins Job found for name: " + projectName).isNotNull();
    return job;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:7,代码来源:ForgeClientAsserts.java


示例11: loadMarkerArtifactAsProperty

import com.offbytwo.jenkins.model.JobWithDetails; //导入依赖的package包/类
/**
 * Loads the marker file of the last build (archived during the build)
 *
 * @param jenkins the jenkins instance we want to load from
 * @return the marker file loaded as a property file (so that it can be easily queried)
 * @throws IOException        Something unexpected went wrong when querying the Jenkins server
 * @throws URISyntaxException Something uunexpected went wrong loading the marker as a property
 */
private Properties loadMarkerArtifactAsProperty(JenkinsServer jenkins) throws IOException, URISyntaxException {
    JobWithDetails detailedJob = jenkins.getJob(JENKINS_JOB_NAME);
    BuildWithDetails lastBuild = detailedJob.getLastBuild().details();
    int buildNbr = lastBuild.getNumber();
    boolean isBuilding = lastBuild.isBuilding();
    log.info("BuildNbr we are examining: " + buildNbr);

    List<Artifact> artifactList = lastBuild.getArtifacts();
    assertEquals("Not the expected number of artifacts", 1, artifactList.size());

    Artifact markerArtifact = artifactList.get(0);
    String markerArtifactFileName = markerArtifact.getFileName();
    assertEquals("The artifact is not the expected one", "marker.txt", markerArtifactFileName);
    InputStream markerArtifactInputStream = lastBuild.details().downloadArtifact(markerArtifact);
    String markerAsText = IOUtils.toString(markerArtifactInputStream, Charset.defaultCharset());
    log.info("\n" + markerAsText);
    StringReader reader = new StringReader(markerAsText);
    Properties markerAsProperty = new Properties();
    markerAsProperty.load(reader);

    //check if the marker matches the build number we expect.
    String buildNbrFromMarker = markerAsProperty.getProperty("BUILD_NUMBER");
    String buildNbrFromQery = String.valueOf(buildNbr);
    assertEquals("The build number from the marker does not match the last build number", buildNbrFromMarker, buildNbrFromQery);
    return markerAsProperty;
}
 
开发者ID:jenkinsci,项目名称:gogs-webhook-plugin,代码行数:35,代码来源:GogsWebHook_IT.java


示例12: assertJobHasBuild

import com.offbytwo.jenkins.model.JobWithDetails; //导入依赖的package包/类
public static Build assertJobHasBuild(JenkinsServer jenkins, String jobName) {
    JobWithDetails job = assertJobExists(jenkins, jobName);
    Build lastBuild = job.getLastBuild();
    assertNotNull("No lastBuild for job `" + jobName + "`", lastBuild);
    return lastBuild;
}
 
开发者ID:fabric8io,项目名称:fabric8-devops,代码行数:7,代码来源:JenkinsAsserts.java


示例13: shouldReturnBuildStatusForBuild

import com.offbytwo.jenkins.model.JobWithDetails; //导入依赖的package包/类
@Test
public void shouldReturnBuildStatusForBuild() throws Exception {
    JobWithDetails job = server.getJobs().get("pr").details();
    BuildWithDetails build = job.getBuilds().get(0).details();
    assertEquals(BuildResult.SUCCESS, build.getResult());
    assertEquals("foobar", build.getParameters().get("REVISION"));
}
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:8,代码来源:JenkinsServerIntegration.java


示例14: testGetJobByName

import com.offbytwo.jenkins.model.JobWithDetails; //导入依赖的package包/类
@Test
public void testGetJobByName() throws Exception {
    final String jobName = "trunk";

    JobWithDetails job = server.getJob(jobName);

    assertEquals("trunk",job.getName());
    assertEquals("trunk",job.getDisplayName());
}
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:10,代码来源:JenkinsServerIntegration.java


示例15: testGetJobByNameDoesntExist

import com.offbytwo.jenkins.model.JobWithDetails; //导入依赖的package包/类
@Test
public void testGetJobByNameDoesntExist() throws Exception {
    final String jobName = "imprettysurethereisnojobwiththisname";

    JobWithDetails job = server.getJob(jobName);

    assertEquals(null, job);
}
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:9,代码来源:JenkinsServerIntegration.java


示例16: call

import com.offbytwo.jenkins.model.JobWithDetails; //导入依赖的package包/类
public Void call() throws InterruptedException, IOException {
    while(true) {
        Thread.sleep(500);
        JobWithDetails jwd = server.getJobs().get(jobName).details();

        try {
            // Throws NPE until the first build succeeds
            jwd.getLastSuccessfulBuild();
        } catch (NullPointerException e) {
            continue;
        }
        // build succeeded
        return null;
    }
}
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:16,代码来源:JenkinsServerIntegration.java


示例17: stop

import com.offbytwo.jenkins.model.JobWithDetails; //导入依赖的package包/类
@Override
public boolean stop(String jobName, String buildIdToStop) {
    //TODO: Remove unnecessary calls to Jenkins for stopping a Build. Try to minimize the number of calls.   
    boolean ans = false;
    try {
        VerigreenLogger.get().log(
                getClass().getName(),
                RuntimeUtils.getCurrentMethodName(),
                String.format("Stopping build (%s)", buildIdToStop));
        JobWithDetails job = CollectorApi.getJenkinsServer().getJob(jobName);
        Build buildToStop = job.getBuildByNumber(Integer.parseInt(buildIdToStop));
        if (buildIdToStop != null) {
            buildToStop.Stop();
            ans = buildToStop.details().getResult().equals(BuildResult.ABORTED);
        } else {
            VerigreenLogger.get().error(
                    getClass().getName(),
                    RuntimeUtils.getCurrentMethodName(),
                    String.format(
                            "There is no build number [%s] for job [%s]",
                            buildIdToStop,
                            jobName));
        }
    } catch (Throwable e) {
        VerigreenLogger.get().error(
                getClass().getName(),
                RuntimeUtils.getCurrentMethodName(),
                String.format("Failed to stop build [%s] for job [%s]", buildIdToStop, jobName),
                e);
    }
    
    return ans;
}
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:34,代码来源:JenkinsVerifier.java


示例18: assertCodeChangeTriggersWorkingBuild

import com.offbytwo.jenkins.model.JobWithDetails; //导入依赖的package包/类
protected Build assertCodeChangeTriggersWorkingBuild(final String projectName, Build firstBuild) throws Exception {
    File cloneDir = new File(getBasedir(), "target/projects/" + projectName);

    String gitUrl = asserGetAppGitCloneURL(forgeClient, projectName);
    Git git = ForgeClientAsserts.assertGitCloneRepo(gitUrl, cloneDir);

    // lets make a dummy commit...
    File readme = new File(cloneDir, "ReadMe.md");
    boolean mustAdd = false;
    String text = "";
    if (readme.exists()) {
        text = IOHelpers.readFully(readme);
    } else {
        mustAdd = true;
    }
    text += "\nupdated at: " + new Date();
    Files.writeToFile(readme, text, Charset.defaultCharset());

    if (mustAdd) {
        AddCommand add = git.add().addFilepattern("*").addFilepattern(".");
        add.call();
    }


    LOG.info("Committing change to " + readme);

    CommitCommand commit = git.commit().setAll(true).setAuthor(forgeClient.getPersonIdent()).setMessage("dummy commit to trigger a rebuild");
    commit.call();
    PushCommand command = git.push();
    command.setCredentialsProvider(forgeClient.createCredentialsProvider());
    command.setRemote("origin").call();

    LOG.info("Git pushed change to " + readme);

    // now lets wait for the next build to start
    int nextBuildNumber = firstBuild.getNumber() + 1;


    Asserts.assertWaitFor(10 * 60 * 1000, new Block() {
        @Override
        public void invoke() throws Exception {
            JobWithDetails job = assertJob(projectName);
            Build lastBuild = job.getLastBuild();
            assertThat(lastBuild.getNumber()).describedAs("Waiting for latest build for job " + projectName + " to start").isGreaterThanOrEqualTo(nextBuildNumber);
        }
    });

    return ForgeClientAsserts.assertBuildCompletes(forgeClient, projectName);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:50,代码来源:ForgeTestSupport.java


示例19: shouldReturnBuildsForJob

import com.offbytwo.jenkins.model.JobWithDetails; //导入依赖的package包/类
@Test
public void shouldReturnBuildsForJob() throws Exception {
    JobWithDetails job = server.getJobs().get("trunk").details();
    assertEquals(5, job.getBuilds().get(0).getNumber());
}
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:6,代码来源:JenkinsServerIntegration.java


示例20: getJobDetails

import com.offbytwo.jenkins.model.JobWithDetails; //导入依赖的package包/类
public JobWithDetails getJobDetails() {
	return jobDetails;
}
 
开发者ID:baloise,项目名称:dashboard-plus,代码行数:4,代码来源:JenkinsData.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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