Search in sources :

Example 1 with TestBuilder

use of org.jvnet.hudson.test.TestBuilder 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"));
}
Also used : FilePath(hudson.FilePath) BuildListener(hudson.model.BuildListener) ArtifactArchiver(hudson.tasks.ArtifactArchiver) Launcher(hudson.Launcher) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) IOException(java.io.IOException) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) TestBuilder(org.jvnet.hudson.test.TestBuilder) Test(org.junit.Test)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 FilePath (hudson.FilePath)1 Launcher (hudson.Launcher)1 BuildListener (hudson.model.BuildListener)1 FreeStyleBuild (hudson.model.FreeStyleBuild)1 FreeStyleProject (hudson.model.FreeStyleProject)1 ArtifactArchiver (hudson.tasks.ArtifactArchiver)1 IOException (java.io.IOException)1 List (java.util.List)1 Test (org.junit.Test)1 TestBuilder (org.jvnet.hudson.test.TestBuilder)1