use of hudson.model.FreeStyleProject in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method getBranchWithEncodedPath.
@Test
public void getBranchWithEncodedPath() throws IOException, ExecutionException, InterruptedException {
Assume.assumeTrue(runAllTests());
WorkflowMultiBranchProject mp = j.jenkins.createProject(WorkflowMultiBranchProject.class, "p");
FreeStyleProject f = j.jenkins.createProject(FreeStyleProject.class, "f");
mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false), new DefaultBranchPropertyStrategy(new BranchProperty[0])));
for (SCMSource source : mp.getSCMSources()) {
assertEquals(mp, source.getOwner());
}
mp.scheduleBuild2(0).getFuture().get();
List<Map> resp = get("/organizations/jenkins/pipelines/p/branches/", List.class);
String href = null;
for (Map r : resp) {
if (r.get("name").equals("feature%2Fux-1")) {
href = (String) ((Map) ((Map) r.get("_links")).get("self")).get("href");
href = StringUtils.substringAfter(href, "/blue/rest");
}
}
Assert.assertNotNull(href);
Map r = get(href);
Assert.assertEquals("feature%2Fux-1", r.get("name"));
}
use of hudson.model.FreeStyleProject in project blueocean-plugin by jenkinsci.
the class PipelineApiTest method parameterizedFreestyleTest.
@Test
public void parameterizedFreestyleTest() throws Exception {
FreeStyleProject p = j.createFreeStyleProject("pp");
p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("version", "1.0", "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("StringParameterDefinition", parameters.get(0).get("type"));
assertEquals("version number", parameters.get(0).get("description"));
assertEquals("1.0", ((Map) parameters.get(0).get("defaultParameterValue")).get("value"));
validatePipeline(p, resp);
resp = post("/organizations/jenkins/pipelines/pp/runs/", ImmutableMap.of("parameters", ImmutableList.of(ImmutableMap.of("name", "version", "value", "2.0"))), 200);
assertEquals("pp", resp.get("pipeline"));
Thread.sleep(1000);
resp = get("/organizations/jenkins/pipelines/pp/runs/1/");
assertEquals("SUCCESS", resp.get("result"));
assertEquals("FINISHED", resp.get("state"));
}
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 ArtifactContainerImplTest method testArtifactsListing.
@Test
public void testArtifactsListing() throws Exception {
FreeStyleProject p = j.createFreeStyleProject(JOB_NAME);
p.getBuildersList().add(new Shell("#!/bin/bash\nmkdir -p test/me/out; cd test/me/out; touch {0..105}.txt"));
p.getPublishersList().add(new ArtifactArchiver("**/*"));
Run r = p.scheduleBuild2(0).waitForStart();
r = j.waitForCompletion(r);
List artifacts = request().get("/organizations/jenkins/pipelines/" + JOB_NAME + "/runs/" + r.getId() + "/artifacts").build(List.class);
Assert.assertEquals(100, artifacts.size());
Assert.assertEquals(0, ((Map) artifacts.get(0)).get("size"));
Assert.assertEquals("test/me/out/0.txt", ((Map) artifacts.get(0)).get("path"));
Assert.assertEquals("/job/artifactTest/1/artifact/test/me/out/0.txt", ((Map) artifacts.get(0)).get("url"));
}
use of hudson.model.FreeStyleProject in project hudson-2.x by hudson.
the class CascadingUtilTest method testRenameCascadingParentLinks.
@Test
@PrepareForTest(Hudson.class)
public void testRenameCascadingParentLinks() throws Exception {
String oldName = "oldCascadingProject";
String newName = "newCascadingProject";
List<Job> jobs = new ArrayList<Job>();
FreeStyleProject project1 = new FreeStyleProjectMock(oldName);
FreeStyleProjectMock project2 = new FreeStyleProjectMock("child");
project2.setCascadingProject(project1);
jobs.add(project1);
jobs.add(project2);
mockStatic(Hudson.class);
Hudson hudson = createMock(Hudson.class);
expect(hudson.getAllItems(Job.class)).andReturn(jobs);
expect(Hudson.getInstance()).andReturn(hudson);
replay(Hudson.class, hudson);
CascadingUtil.renameCascadingParentLinks(oldName, newName);
verify(Hudson.class, hudson);
assertEquals(newName, project2.getCascadingProjectName());
}
Aggregations