use of hudson.model.FreeStyleProject in project blueocean-plugin by jenkinsci.
the class PipelineApiTest method parameterizedFreestyleTestWithoutDefaultParam.
@Test
public void parameterizedFreestyleTestWithoutDefaultParam() throws Exception {
FreeStyleProject p = j.createFreeStyleProject("pp");
p.addProperty(new ParametersDefinitionProperty(new TestStringParameterDefinition("version", null, "version number")));
p.getBuildersList().add(new Shell("echo hello!"));
Map resp = get("/organizations/jenkins/pipelines/pp/");
List<Map<String, Object>> parameters = (List<Map<String, Object>>) resp.get("parameters");
assertEquals(1, parameters.size());
assertEquals("version", parameters.get(0).get("name"));
assertEquals("TestStringParameterDefinition", parameters.get(0).get("type"));
assertEquals("version number", parameters.get(0).get("description"));
assertNull(parameters.get(0).get("defaultParameterValue"));
validatePipeline(p, resp);
resp = post("/organizations/jenkins/pipelines/pp/runs/", ImmutableMap.of("parameters", ImmutableList.of()), 400);
}
use of hudson.model.FreeStyleProject in project blueocean-plugin by jenkinsci.
the class PipelineApiTest method testPipelineQueue.
@Test
public void testPipelineQueue() throws Exception {
FreeStyleProject p1 = j.createFreeStyleProject("pipeline1");
p1.setConcurrentBuild(true);
p1.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("test", "test")));
p1.getBuildersList().add(new Shell("echo hello!\nsleep 300"));
p1.scheduleBuild2(0).waitForStart();
p1.scheduleBuild2(0).waitForStart();
Jenkins.getInstance().getQueue().schedule(p1, 0, new ParametersAction(new StringParameterValue("test", "test1")), new CauseAction(new Cause.UserIdCause()));
Jenkins.getInstance().getQueue().schedule(p1, 0, new ParametersAction(new StringParameterValue("test", "test2")), new CauseAction(new Cause.UserIdCause()));
List queue = request().get("/organizations/jenkins/pipelines/pipeline1/queue").build(List.class);
Assert.assertEquals(2, queue.size());
Assert.assertEquals(4, ((Map) queue.get(0)).get("expectedBuildNumber"));
Assert.assertEquals(3, ((Map) queue.get(1)).get("expectedBuildNumber"));
Assert.assertEquals("Waiting for next available executor", ((Map) queue.get(0)).get("causeOfBlockage"));
Assert.assertEquals("Waiting for next available executor", ((Map) queue.get(1)).get("causeOfBlockage"));
Run r = QueueUtil.getRun(p1, Long.parseLong((String) ((Map) queue.get(0)).get("id")));
// its not moved out of queue yet
assertNull(r);
}
use of hudson.model.FreeStyleProject in project blueocean-plugin by jenkinsci.
the class PipelineApiTest method getPipelineRunWithTestResult.
@Test
public void getPipelineRunWithTestResult() throws Exception {
FreeStyleProject p = j.createFreeStyleProject("pipeline4");
p.getBuildersList().add(new Shell("echo '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<testsuite xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd\" name=\"io.jenkins.blueocean.jsextensions.JenkinsJSExtensionsTest\" time=\"35.7\" tests=\"1\" errors=\"0\" skipped=\"0\" failures=\"0\">\n" + " <properties>\n" + " </properties>\n" + " <testcase name=\"test\" classname=\"io.jenkins.blueocean.jsextensions.JenkinsJSExtensionsTest\" time=\"34.09\"/>\n" + "</testsuite>' > test-result.xml"));
p.getPublishersList().add(new JUnitResultArchiver("*.xml"));
FreeStyleBuild b = p.scheduleBuild2(0).get();
TestResultAction resultAction = b.getAction(TestResultAction.class);
assertEquals("io.jenkins.blueocean.jsextensions.JenkinsJSExtensionsTest", resultAction.getResult().getSuites().iterator().next().getName());
j.assertBuildStatusSuccess(b);
Map resp = get("/organizations/jenkins/pipelines/pipeline4/runs/" + b.getId());
// discover TestResultAction super classes
get("/classes/hudson.tasks.junit.TestResultAction/");
// get junit rest report
get("/organizations/jenkins/pipelines/pipeline4/runs/" + b.getId() + "/testReport/result/");
}
Aggregations