Search in sources :

Example 1 with WrapperBuilder

use of hudson.plugins.copyartifact.testutils.WrapperBuilder in project copyartifact-plugin by jenkinsci.

the class CopyArtifactTest method testEnvDataWrapped.

@Issue("JENKINS-18762")
@Test
public void testEnvDataWrapped() throws Exception {
    FreeStyleProject upstream = rule.createFreeStyleProject("upstream");
    upstream.getBuildersList().add(new FileWriteBuilder("artifact.txt", "foobar"));
    upstream.getPublishersList().add(new ArtifactArchiver("**/*", "", false, false));
    FreeStyleBuild upstreamBuild = upstream.scheduleBuild2(0).get();
    rule.assertBuildStatusSuccess(upstreamBuild);
    FreeStyleProject downstream = rule.createFreeStyleProject();
    downstream.getBuildersList().add(new WrapperBuilder(CopyArtifactUtil.createCopyArtifact("upstream", "", new SpecificBuildSelector(Integer.toString(upstreamBuild.getNumber())), "**/*", "", "", false, false, false)));
    CaptureEnvironmentBuilder envStep = new CaptureEnvironmentBuilder();
    downstream.getBuildersList().add(envStep);
    FreeStyleBuild downstreamBuild = downstream.scheduleBuild2(0).get();
    rule.assertBuildStatusSuccess(downstreamBuild);
    assertFile(true, "artifact.txt", downstreamBuild);
    assertEquals(Integer.toString(upstreamBuild.getNumber()), envStep.getEnvVars().get("COPYARTIFACT_BUILD_NUMBER_UPSTREAM"));
}
Also used : WrapperBuilder(hudson.plugins.copyartifact.testutils.WrapperBuilder) ArtifactArchiver(hudson.tasks.ArtifactArchiver) FileWriteBuilder(hudson.plugins.copyartifact.testutils.FileWriteBuilder) CaptureEnvironmentBuilder(org.jvnet.hudson.test.CaptureEnvironmentBuilder) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Aggregations

FileWriteBuilder (hudson.plugins.copyartifact.testutils.FileWriteBuilder)1 WrapperBuilder (hudson.plugins.copyartifact.testutils.WrapperBuilder)1 ArtifactArchiver (hudson.tasks.ArtifactArchiver)1 Test (org.junit.Test)1 CaptureEnvironmentBuilder (org.jvnet.hudson.test.CaptureEnvironmentBuilder)1 Issue (org.jvnet.hudson.test.Issue)1