use of hudson.plugins.copyartifact.testutils.FileWriteBuilder in project copyartifact-plugin by jenkinsci.
the class CopyArtifactTest method testPermissionWhenParameterizedForMatrixConfig.
@Test
public void testPermissionWhenParameterizedForMatrixConfig() throws Exception {
rule.jenkins.setSecurityRealm(rule.createDummySecurityRealm());
MockAuthorizationStrategy auth = new MockAuthorizationStrategy().grant(Jenkins.READ).onRoot().toEveryone();
rule.jenkins.setAuthorizationStrategy(auth);
MatrixProject src = rule.jenkins.createProject(MatrixProject.class, "testMatrix");
AxisList axisList = new AxisList(new Axis("FOO", "foo", "bar"));
src.setAxes(axisList);
auth.grant(Item.READ).onItems(src).toEveryone();
auth.grant(Item.READ).onItems(src.getItem(new Combination(axisList, "foo"))).toEveryone();
auth.grant(Item.READ).onItems(src.getItem(new Combination(axisList, "bar"))).toEveryone();
src.getBuildersList().add(new FileWriteBuilder("foo.txt", "foo"));
src.getPublishersList().add(new ArtifactArchiver("*.txt"));
rule.assertBuildStatusSuccess(src.scheduleBuild2(0));
FreeStyleProject p = createProject("testMatrix/FOO=$FOO", null, "", "", false, false, false, true);
ParameterDefinition paramDef = new StringParameterDefinition("FOO", "FOO");
ParametersDefinitionProperty paramsDef = new ParametersDefinitionProperty(paramDef);
p.addProperty(paramsDef);
// Build step should succeed when this parameter expands to a job accessible to
// authenticated users, even when selecting a single matrix config, not the parent job:
FreeStyleBuild b = p.scheduleBuild2(0, new UserCause(), new ParametersAction(new StringParameterValue("FOO", "foo"))).get();
assertFile(true, "foo.txt", b);
rule.assertBuildStatusSuccess(b);
}
use of hudson.plugins.copyartifact.testutils.FileWriteBuilder in project copyartifact-plugin by jenkinsci.
the class CopyArtifactTest method testEnvDataInMavenProject.
@Issue("JENKINS-16028")
@Test
public void testEnvDataInMavenProject() 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);
MavenModuleSet downstream = setupMavenJob();
downstream.getPrebuilders().add(CopyArtifactUtil.createCopyArtifact("upstream", "", new SpecificBuildSelector(Integer.toString(upstreamBuild.getNumber())), "**/*", "", "", false, false, false));
CaptureEnvironmentBuilder envStep = new CaptureEnvironmentBuilder();
downstream.getPrebuilders().add(envStep);
MavenModuleSetBuild 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"));
}
Aggregations