Merge pull request #83 from cloudbees/feature/UX-216
UX-216# jobs inside folder were not handled correctly resulting in 404
This commit is contained in:
commit
5a8899e7a4
|
@ -2,7 +2,6 @@ package io.jenkins.blueocean.service.embedded.rest;
|
|||
|
||||
import hudson.model.BuildableItem;
|
||||
import hudson.model.Job;
|
||||
import hudson.model.TopLevelItem;
|
||||
import io.jenkins.blueocean.commons.ServiceException;
|
||||
import io.jenkins.blueocean.rest.model.BluePipeline;
|
||||
import io.jenkins.blueocean.rest.model.BluePipelineContainer;
|
||||
|
@ -10,7 +9,6 @@ import jenkins.branch.MultiBranchProject;
|
|||
import jenkins.model.Jenkins;
|
||||
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -21,11 +19,11 @@ import java.util.List;
|
|||
public class PipelineContainerImpl extends BluePipelineContainer {
|
||||
@Override
|
||||
public BluePipeline get(String name) {
|
||||
TopLevelItem p = Jenkins.getActiveInstance().getItem(name);
|
||||
if(p instanceof Job){
|
||||
return new PipelineImpl((Job)p);
|
||||
}else if (p instanceof MultiBranchProject) {
|
||||
return new MultiBranchPipelineImpl((MultiBranchProject) p);
|
||||
|
||||
for (BluePipeline bluePipeline : this) {
|
||||
if (bluePipeline.getName().equals(name)) {
|
||||
return bluePipeline;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: I'm going to turn this into a decorator annotation
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.junit.Before;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.jvnet.hudson.test.JenkinsRule;
|
||||
import org.jvnet.hudson.test.MockFolder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -47,6 +48,21 @@ public class PipelineApiTest {
|
|||
RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFolderPipelineTest() throws IOException {
|
||||
MockFolder folder = j.createFolder("folder1");
|
||||
Project p = folder.createProject(FreeStyleProject.class, "test1");
|
||||
|
||||
RestAssured.given().log().all().get("/organizations/jenkins/pipelines/test1")
|
||||
.then().log().all()
|
||||
.statusCode(200)
|
||||
.body("organization", Matchers.equalTo("jenkins"))
|
||||
.body("name", Matchers.equalTo("test1"))
|
||||
.body("displayName", Matchers.equalTo("test1"))
|
||||
.body("weatherScore", Matchers.is(p.getBuildHealth().getScore()));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getPipelineTest() throws IOException {
|
||||
Project p = j.createFreeStyleProject("pipeline1");
|
||||
|
|
Loading…
Reference in New Issue