Search in sources :

Example 1 with BlueArtifactContainer

use of io.jenkins.blueocean.rest.model.BlueArtifactContainer 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 = getClass().getResource("HTMLArtifactTest.jenkinsfile");
    String jenkinsFile = IOUtils.toString(resource, StandardCharsets.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, StreamSupport.stream(artifacts.spliterator(), false).count());
    BlueArtifact artifact = artifacts.iterator().next();
    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.assertNotNull(artifact.getUrl());
    Assert.assertEquals(-1, artifact.getSize());
    Assert.assertFalse(artifact.isDownloadable());
}
Also used : CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) BlueArtifact(io.jenkins.blueocean.rest.model.BlueArtifact) BluePipeline(io.jenkins.blueocean.rest.model.BluePipeline) BlueArtifactContainer(io.jenkins.blueocean.rest.model.BlueArtifactContainer) Run(hudson.model.Run) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) URL(java.net.URL) PipelineBaseTest(io.jenkins.blueocean.rest.impl.pipeline.PipelineBaseTest) Test(org.junit.Test)

Aggregations

Run (hudson.model.Run)1 PipelineBaseTest (io.jenkins.blueocean.rest.impl.pipeline.PipelineBaseTest)1 BlueArtifact (io.jenkins.blueocean.rest.model.BlueArtifact)1 BlueArtifactContainer (io.jenkins.blueocean.rest.model.BlueArtifactContainer)1 BluePipeline (io.jenkins.blueocean.rest.model.BluePipeline)1 URL (java.net.URL)1 CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)1 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)1 Test (org.junit.Test)1