Search in sources :

Example 1 with AcceptHeader

use of org.kohsuke.stapler.AcceptHeader in project blueocean-plugin by jenkinsci.

the class PipelineApiTest method getPipelineJobRunsLogTest.

@Test
public void getPipelineJobRunsLogTest() throws Exception {
    WorkflowJob job1 = j.jenkins.createProject(WorkflowJob.class, "pipeline1");
    job1.setDefinition(new CpsFlowDefinition("" + "node {" + "   stage ('Build1'); " + "   echo ('Building'); " + "   stage ('Test1'); " + "   echo ('Testing'); " + "}"));
    WorkflowRun b1 = job1.scheduleBuild2(0).get();
    j.assertBuildStatusSuccess(b1);
    HttpResponse<String> response = get("/organizations/jenkins/pipelines/pipeline1/runs/" + b1.getId() + "/log?start=0", 200, "text/html", HttpResponse.class);
    AcceptHeader acceptHeader = new AcceptHeader(response.getHeaders().getFirst("Content-Type"));
    Assert.assertNotNull(acceptHeader.select("text/plain"));
    int size = Integer.parseInt(response.getHeaders().getFirst("X-Text-Size"));
    System.out.println(response.getBody());
    Assert.assertTrue(size > 0);
}
Also used : CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) AcceptHeader(org.kohsuke.stapler.AcceptHeader) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) Test(org.junit.Test)

Aggregations

CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)1 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)1 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)1 Test (org.junit.Test)1 AcceptHeader (org.kohsuke.stapler.AcceptHeader)1