use of hudson.model.FreeStyleProject in project blueocean-plugin by jenkinsci.
the class PipelineNodeTest method downstreamBuildLinks.
@Test
@Issue("JENKINS-38339")
public void downstreamBuildLinks() throws Exception {
FreeStyleProject downstream1 = j.createFreeStyleProject("downstream1");
FreeStyleProject downstream2 = j.createFreeStyleProject("downstream2");
WorkflowJob upstream = j.createProject(WorkflowJob.class, "upstream");
URL resource = Resources.getResource(getClass(), "downstreamBuildLinks.jenkinsfile");
String jenkinsFile = Resources.toString(resource, Charsets.UTF_8);
upstream.setDefinition(new CpsFlowDefinition(jenkinsFile, true));
j.assertBuildStatus(Result.SUCCESS, upstream.scheduleBuild2(0));
WorkflowRun r = upstream.getLastBuild();
List<Map> resp = get("/organizations/jenkins/pipelines/upstream/runs/" + r.getId() + "/nodes/", List.class);
assertEquals("number of nodes", 5, resp.size());
Matcher actionMatcher1 = new NodeDownstreamBuildActionMatcher("downstream1");
Matcher actionMatcher2 = new NodeDownstreamBuildActionMatcher("downstream2");
List<Map> actions = (List<Map>) resp.get(2).get("actions");
assertThat("node #2 contains a link to downstream1", actions, hasItem(actionMatcher1));
actions = (List<Map>) resp.get(3).get("actions");
assertThat("node #3 contains a link to downstream2", actions, hasItem(actionMatcher2));
actions = (List<Map>) resp.get(4).get("actions");
assertThat("node #4 contains a link to downstream1", actions, hasItem(actionMatcher1));
assertThat("node #4 contains a link to downstream1", actions, hasItem(actionMatcher2));
}
use of hudson.model.FreeStyleProject in project blueocean-plugin by jenkinsci.
the class ArtifactContainerImplTest method testArtifact.
// TODO: needs viveks input
@Test
@Ignore
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());
}
use of hudson.model.FreeStyleProject in project blueocean-plugin by jenkinsci.
the class ContainerFilterTest method testPagedFilter.
@Test
public void testPagedFilter() throws IOException {
StaplerRequest request = mock(StaplerRequest.class);
when(request.getParameter("filter")).thenReturn("itemgroup-only");
mockStatic(Stapler.class);
when(Stapler.getCurrentRequest()).thenReturn(request);
List<Item> items = new ArrayList<>();
MockFolder folder = j.createFolder("folder");
for (int i = 0; i < 50; i++) {
FreeStyleProject job = folder.createProject(FreeStyleProject.class, "job" + i);
items.add(folder.createProject(MockFolder.class, "subFolder" + i));
items.add(job);
}
assertEquals(100, items.size());
// there are total 50 folders in items, we want 25 of them starting 25th ending at 49th.
Collection<Item> jobs = ContainerFilter.filter(items, 25, 25);
assertEquals(25, jobs.size());
int i = 25;
for (Item item : jobs) {
assertTrue(item instanceof ItemGroup);
assertEquals("subFolder" + i++, item.getName());
}
}
use of hudson.model.FreeStyleProject in project blueocean-plugin by jenkinsci.
the class PipelineApiTest method shouldFailToGetRunForInvalidRunId2.
@Test
public void shouldFailToGetRunForInvalidRunId2() throws Exception {
FreeStyleProject p = j.createFreeStyleProject("pipeline6");
p.getBuildersList().add(new Shell("echo hello!\nsleep 1"));
get("/organizations/jenkins/pipelines/pipeline6/runs/xyz", 404, Map.class);
}
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);
String log = get("/organizations/jenkins/pipelines/pipeline4/runs/" + b.getId() + "/log", String.class);
System.out.println(log);
assertNotNull(log);
}
Aggregations