use of org.jenkinsci.plugins.workflow.job.WorkflowRun in project blueocean-plugin by jenkinsci.
the class PipelineNodeTest method stepStatusForUnstableBuild.
//JENKINS-39203
@Test
public void stepStatusForUnstableBuild() throws Exception {
String p = "node {\n" + " echo 'Hello World'\n" + " try{\n" + " echo 'Inside try'\n" + " }finally{\n" + " sh 'echo \"blah\"' \n" + " currentBuild.result = \"UNSTABLE\"\n" + " }\n" + "}";
WorkflowJob job1 = j.jenkins.createProject(WorkflowJob.class, "pipeline1");
job1.setDefinition(new CpsFlowDefinition(p));
WorkflowRun b1 = job1.scheduleBuild2(0).get();
j.assertBuildStatus(Result.UNSTABLE, b1);
List<Map> resp = get("/organizations/jenkins/pipelines/pipeline1/runs/1/steps/", List.class);
Assert.assertEquals(resp.size(), 3);
for (int i = 0; i < resp.size(); i++) {
Map rn = resp.get(i);
Assert.assertEquals(rn.get("result"), "SUCCESS");
Assert.assertEquals(rn.get("state"), "FINISHED");
}
}
use of org.jenkinsci.plugins.workflow.job.WorkflowRun in project blueocean-plugin by jenkinsci.
the class PipelineApiTest method getPipelineJobAbortTest.
@Test
public void getPipelineJobAbortTest() throws Exception {
WorkflowJob job1 = j.jenkins.createProject(WorkflowJob.class, "pipeline1");
job1.setDefinition(new CpsFlowDefinition("" + "node {" + " stage ('Build1'); " + " sh('sleep 60') " + " stage ('Test1'); " + " echo ('Testing'); " + "}"));
WorkflowRun b1 = job1.scheduleBuild2(0).waitForStart();
for (int i = 0; i < 10; i++) {
b1.doStop();
if (b1.getResult() != null) {
break;
}
Thread.sleep(1000);
}
j.assertBuildStatus(Result.ABORTED, b1);
Map r = get("/organizations/jenkins/pipelines/pipeline1/runs/1");
validateRun(b1, r);
}
use of org.jenkinsci.plugins.workflow.job.WorkflowRun in project blueocean-plugin by jenkinsci.
the class PipelineNodeTest method KyotoNodesFailureTest2.
@Test
public void KyotoNodesFailureTest2() throws Exception {
WorkflowJob job1 = j.jenkins.createProject(WorkflowJob.class, "pipeline1");
job1.setDefinition(new CpsFlowDefinition("pipeline {\n" + " agent any\n" + " stages {\n" + " stage ('Build') {\n" + "steps{\n" + " sh 'echo \"Building\"'\n" + "}\n" + " }\n" + " stage ('Test') {\n" + "steps{\n" + " sh 'echo \"Building\"'\n" + " sh 'echo2 \"Building finished\"'\n" + "}\n" + " }\n" + " stage ('Deploy') {\n" + "steps{\n" + " sh 'echo \"Building\"'\n" + "}\n" + " }\n" + " }\n" + "}\n"));
WorkflowRun b1 = job1.scheduleBuild2(0).get();
j.assertBuildStatus(Result.FAILURE, b1);
List<Map> nodes = get("/organizations/jenkins/pipelines/pipeline1/runs/1/nodes/", List.class);
Assert.assertEquals(3, nodes.size());
Assert.assertEquals("SUCCESS", nodes.get(0).get("result"));
Assert.assertEquals("FINISHED", nodes.get(0).get("state"));
Assert.assertEquals("FAILURE", nodes.get(1).get("result"));
Assert.assertEquals("FINISHED", nodes.get(1).get("state"));
}
Aggregations