use of org.jenkinsci.plugins.workflow.job.WorkflowJob 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.WorkflowJob in project blueocean-plugin by jenkinsci.
the class PipelineApiTest method getPipelineJobsTest.
@Test
public void getPipelineJobsTest() throws IOException {
WorkflowJob p1 = j.jenkins.createProject(WorkflowJob.class, "pipeline1");
WorkflowJob p2 = j.jenkins.createProject(WorkflowJob.class, "pipeline2");
List<Map> resp = get("/organizations/jenkins/pipelines/", List.class);
WorkflowJob[] projects = { p1, p2 };
Assert.assertEquals(projects.length, resp.size());
for (int i = 0; i < projects.length; i++) {
Map lr = resp.get(i);
validatePipeline(projects[i], lr);
}
}
use of org.jenkinsci.plugins.workflow.job.WorkflowJob 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