use of io.jenkins.blueocean.service.embedded.rest.ArtifactContainerImpl 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"));
String artifactName = (String) ((Map) artifacts.get(0)).get("name");
String name = ArtifactImpl.class.getName() + ":" + artifactName;
ArtifactContainerImpl container = new ArtifactContainerImpl(b, new Reachable() {
@Override
public Link getLink() {
return new Link("/blue/rest/organizations/jenkins/pipelines/pipeline1/runs/1/artifacts/");
}
});
BlueArtifact blueArtifact = container.get(name);
assertNotNull(blueArtifact);
}
Aggregations