use of io.jenkins.blueocean.rest.model.BlueArtifact in project blueocean-plugin by jenkinsci.
the class HTMLArtifactTest method resolveArtifact.
@Test
public void resolveArtifact() throws Exception {
WorkflowJob p = j.createProject(WorkflowJob.class, "project");
URL resource = Resources.getResource(getClass(), "HTMLArtifactTest.jenkinsfile");
String jenkinsFile = Resources.toString(resource, Charsets.UTF_8);
p.setDefinition(new CpsFlowDefinition(jenkinsFile, true));
p.save();
Run r = p.scheduleBuild2(0).waitForStart();
j.waitForCompletion(r);
BluePipeline bluePipeline = (BluePipeline) BluePipelineFactory.resolve(p);
BlueArtifactContainer artifacts = bluePipeline.getLatestRun().getArtifacts();
Assert.assertEquals(1, Iterators.size(artifacts.iterator()));
BlueArtifact artifact = Iterators.getOnlyElement(artifacts.iterator());
Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/project/runs/1/artifacts/io.jenkins.blueocean.htmlpublisher.HTMLArtifact%253AMy%252520Cool%252520report/", artifact.getLink().getHref());
Assert.assertEquals("My Cool report", artifact.getName());
Assert.assertEquals("My Cool report", artifact.getPath());
Assert.assertEquals("/job/project/1/My_Cool_report", artifact.getUrl());
Assert.assertEquals(-1, artifact.getSize());
Assert.assertFalse(artifact.isDownloadable());
}
use of io.jenkins.blueocean.rest.model.BlueArtifact 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