use of hudson.model.FreeStyleProject in project blueocean-plugin by jenkinsci.
the class PipelineApiTest method getPipelineRunsTest.
@Test
public void getPipelineRunsTest() throws Exception {
FreeStyleProject p = j.createFreeStyleProject("pipeline6");
p.getBuildersList().add(new Shell("echo hello!\nsleep 1"));
FreeStyleBuild b = p.scheduleBuild2(0).get();
j.assertBuildStatusSuccess(b);
List<Map> resp = get("/organizations/jenkins/pipelines/pipeline6/runs", List.class);
assertEquals(1, resp.size());
Map lr = resp.get(0);
validateRun(b, lr);
}
use of hudson.model.FreeStyleProject in project blueocean-plugin by jenkinsci.
the class PipelineApiTest method testNewPipelineQueueItem.
@Test
public void testNewPipelineQueueItem() throws Exception {
FreeStyleProject p1 = j.createFreeStyleProject("pipeline1");
FreeStyleProject p2 = j.createFreeStyleProject("pipeline2");
FreeStyleProject p3 = j.createFreeStyleProject("pipeline3");
p1.getBuildersList().add(new Shell("echo hello!\nsleep 300"));
p2.getBuildersList().add(new Shell("echo hello!\nsleep 300"));
p3.getBuildersList().add(new Shell("echo hello!\nsleep 300"));
p1.scheduleBuild2(0).waitForStart();
p2.scheduleBuild2(0).waitForStart();
Map r = request().post("/organizations/jenkins/pipelines/pipeline3/runs/").build(Map.class);
assertNotNull(p3.getQueueItem());
String id = Long.toString(p3.getQueueItem().getId());
assertEquals(id, r.get("id"));
delete("/organizations/jenkins/pipelines/pipeline3/queue/" + id + "/");
Queue.Item item = j.jenkins.getQueue().getItem(Long.parseLong(id));
assertTrue(item instanceof Queue.LeftItem);
assertTrue(((Queue.LeftItem) item).isCancelled());
}
use of hudson.model.FreeStyleProject in project blueocean-plugin by jenkinsci.
the class PipelineApiTest method testArtifactsRunApi.
@Test
public void testArtifactsRunApi() throws Exception {
FreeStyleProject p = j.createFreeStyleProject("pipeline1");
p.getBuildersList().add(new TestBuilder() {
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
FilePath ws = build.getWorkspace();
if (ws == null) {
return false;
}
FilePath dir = ws.child("dir");
dir.mkdirs();
dir.child("fizz").write("contents", null);
dir.child("lodge").symlinkTo("fizz", listener);
return true;
}
});
ArtifactArchiver aa = new ArtifactArchiver("dir/fizz");
aa.setAllowEmptyArchive(true);
p.getPublishersList().add(aa);
FreeStyleBuild b = j.assertBuildStatusSuccess(p.scheduleBuild2(0));
List artifacts = get("/organizations/jenkins/pipelines/pipeline1/runs/" + b.getId() + "/artifacts", List.class);
assertEquals(1, artifacts.size());
assertEquals("fizz", ((Map) artifacts.get(0)).get("name"));
}
use of hudson.model.FreeStyleProject in project blueocean-plugin by jenkinsci.
the class PipelineApiTest method getPipelineRunTest.
@Test
public void getPipelineRunTest() throws Exception {
FreeStyleProject p = j.createFreeStyleProject("pipeline4");
p.getBuildersList().add(new Shell("echo hello!\nsleep 1"));
FreeStyleBuild b = p.scheduleBuild2(0).get();
j.assertBuildStatusSuccess(b);
Map resp = get("/organizations/jenkins/pipelines/pipeline4/runs/" + b.getId());
validateRun(b, resp);
}
use of hudson.model.FreeStyleProject in project blueocean-plugin by jenkinsci.
the class ArtifactContainerImplTest method testArtifact.
//@Test TODO needs viveks input
public void testArtifact() throws Exception {
FreeStyleProject p = j.createFreeStyleProject(JOB_NAME);
p.getBuildersList().add(new Shell("mkdir -p test/me/out; touch test/me/out/{{a..z},{A..Z},{0..99}}.txt"));
p.getPublishersList().add(new ArtifactArchiver("**/*"));
Run r = p.scheduleBuild2(0).waitForStart();
r = j.waitForCompletion(r);
Map artifact = request().get("/organizations/jenkins/pipelines/" + JOB_NAME + "/runs/" + r.getId() + "/artifacts/test%252Fme%252Fout%252F0.txt").build(Map.class);
Assert.assertEquals(100, artifact.size());
}
Aggregations