Search in sources :

Example 1 with CopyArtifact

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

the class LegacyJobConfigMigrationMonitorTest method setupAnonymousJob.

private void setupAnonymousJob() throws Exception {
    j.jenkins.setSecurityRealm(j.createDummySecurityRealm());
    MockAuthorizationStrategy auth = new MockAuthorizationStrategy();
    j.jenkins.setAuthorizationStrategy(auth);
    FreeStyleProject toBeCopied = j.createFreeStyleProject("to-be-copied");
    auth.grant(Item.READ).onItems(toBeCopied).toEveryone();
    toBeCopied.getBuildersList().add(new FileWriteBuilder("test.txt", "test"));
    toBeCopied.getPublishersList().add(new ArtifactArchiver("**"));
    FreeStyleProject copier = j.createFreeStyleProject("copier");
    copier.getBuildersList().add(new CopyArtifact(toBeCopied.getFullName()));
}
Also used : ArtifactArchiver(hudson.tasks.ArtifactArchiver) MockAuthorizationStrategy(org.jvnet.hudson.test.MockAuthorizationStrategy) FileWriteBuilder(hudson.plugins.copyartifact.testutils.FileWriteBuilder) CopyArtifact(hudson.plugins.copyartifact.CopyArtifact) FreeStyleProject(hudson.model.FreeStyleProject)

Example 2 with CopyArtifact

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

the class LegacyJobConfigMigrationMonitorMigrationTest method migrate_freestyle_to_freestyle.

@Test
public void migrate_freestyle_to_freestyle() throws Exception {
    FreeStyleProject src = j.createFreeStyleProject();
    src.getBuildersList().add(new FileWriteBuilder("artifact.txt", "artifact content"));
    src.getPublishersList().add(new ArtifactArchiver("**/*"));
    j.assertBuildStatusSuccess(src.scheduleBuild2(0));
    FreeStyleProject dst = j.createFreeStyleProject();
    dst.getBuildersList().add(new CopyArtifact(src.getFullName()));
    j.assertBuildStatusSuccess(dst.scheduleBuild2(0));
    CopyArtifactConfiguration.get().setMode(CopyArtifactCompatibilityMode.PRODUCTION);
    j.assertBuildStatus(Result.FAILURE, dst.scheduleBuild2(0));
    assertTrue(applyAutoMigrationToAll());
    j.assertBuildStatusSuccess(dst.scheduleBuild2(0));
}
Also used : ArtifactArchiver(hudson.tasks.ArtifactArchiver) FileWriteBuilder(hudson.plugins.copyartifact.testutils.FileWriteBuilder) CopyArtifact(hudson.plugins.copyartifact.CopyArtifact) FreeStyleProject(hudson.model.FreeStyleProject) WorkflowMultiBranchProjectTest(org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProjectTest) Test(org.junit.Test)

Example 3 with CopyArtifact

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

the class LegacyJobConfigMigrationMonitorMigrationTest method migrate_pipeline_to_maven.

@Test
public void migrate_pipeline_to_maven() throws Exception {
    WorkflowJob src = j.createProject(WorkflowJob.class);
    src.setDefinition(new CpsFlowDefinition("node {" + "writeFile(text: 'artifact', file: 'artifact.txt');" + "archiveArtifacts(artifacts: 'artifact.txt');" + "}", true));
    j.assertBuildStatusSuccess(src.scheduleBuild2(0));
    ToolInstallations.configureMaven3();
    MavenModuleSet dst = j.createProject(MavenModuleSet.class);
    dst.setScm(j.getExtractResourceScm(tempFolder, getClass().getResource("../maven-job")));
    dst.setRunHeadless(true);
    dst.setGoals("clean package -Dmaven.compiler.source=1.8 -Dmaven.compiler.target=1.8");
    dst.getPrebuilders().add(new CopyArtifact(src.getFullName()));
    j.assertBuildStatusSuccess(dst.scheduleBuild2(0));
    CopyArtifactConfiguration.get().setMode(CopyArtifactCompatibilityMode.PRODUCTION);
    j.assertBuildStatus(Result.FAILURE, dst.scheduleBuild2(0));
    assertTrue(applyAutoMigrationToAll());
    j.assertBuildStatusSuccess(dst.scheduleBuild2(0));
}
Also used : CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) CopyArtifact(hudson.plugins.copyartifact.CopyArtifact) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) MavenModuleSet(hudson.maven.MavenModuleSet) WorkflowMultiBranchProjectTest(org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProjectTest) Test(org.junit.Test)

Example 4 with CopyArtifact

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

the class LegacyJobConfigMigrationMonitorMigrationTest method migrate_pipeline_to_matrix.

@Test
public void migrate_pipeline_to_matrix() throws Exception {
    WorkflowJob src = j.createProject(WorkflowJob.class);
    src.setDefinition(new CpsFlowDefinition("node {" + "writeFile(text: 'artifact', file: 'artifact.txt');" + "archiveArtifacts(artifacts: 'artifact.txt');" + "}", true));
    j.assertBuildStatusSuccess(src.scheduleBuild2(0));
    MatrixProject dst = j.createProject(MatrixProject.class);
    AxisList axisList = new AxisList(new Axis("axis1", "value1", "value2"));
    dst.setAxes(axisList);
    dst.getBuildersList().add(new CopyArtifact(src.getFullName()));
    j.assertBuildStatusSuccess(dst.scheduleBuild2(0));
    CopyArtifactConfiguration.get().setMode(CopyArtifactCompatibilityMode.PRODUCTION);
    j.assertBuildStatus(Result.FAILURE, dst.scheduleBuild2(0));
    assertTrue(applyAutoMigrationToAll());
    j.assertBuildStatusSuccess(dst.scheduleBuild2(0));
}
Also used : AxisList(hudson.matrix.AxisList) CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) CopyArtifact(hudson.plugins.copyartifact.CopyArtifact) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) MatrixProject(hudson.matrix.MatrixProject) Axis(hudson.matrix.Axis) WorkflowMultiBranchProjectTest(org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProjectTest) Test(org.junit.Test)

Example 5 with CopyArtifact

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

the class LegacyJobConfigMigrationMonitorTest method setupRestrictedJob.

private void setupRestrictedJob() throws Exception {
    j.jenkins.setSecurityRealm(j.createDummySecurityRealm());
    MockAuthorizationStrategy auth = new MockAuthorizationStrategy();
    j.jenkins.setAuthorizationStrategy(auth);
    FreeStyleProject toBeCopied = j.createFreeStyleProject("to-be-copied");
    auth.grant(Item.READ).onItems(toBeCopied).to("admin");
    toBeCopied.getBuildersList().add(new FileWriteBuilder("test.txt", "test"));
    toBeCopied.getPublishersList().add(new ArtifactArchiver("**"));
    FreeStyleProject copier = j.createFreeStyleProject("copier");
    copier.getBuildersList().add(new CopyArtifact(toBeCopied.getFullName()));
}
Also used : ArtifactArchiver(hudson.tasks.ArtifactArchiver) MockAuthorizationStrategy(org.jvnet.hudson.test.MockAuthorizationStrategy) FileWriteBuilder(hudson.plugins.copyartifact.testutils.FileWriteBuilder) CopyArtifact(hudson.plugins.copyartifact.CopyArtifact) FreeStyleProject(hudson.model.FreeStyleProject)

Aggregations

CopyArtifact (hudson.plugins.copyartifact.CopyArtifact)7 FreeStyleProject (hudson.model.FreeStyleProject)4 FileWriteBuilder (hudson.plugins.copyartifact.testutils.FileWriteBuilder)4 ArtifactArchiver (hudson.tasks.ArtifactArchiver)4 WorkflowMultiBranchProjectTest (org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProjectTest)3 Test (org.junit.Test)3 MockAuthorizationStrategy (org.jvnet.hudson.test.MockAuthorizationStrategy)3 CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)2 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)2 Axis (hudson.matrix.Axis)1 AxisList (hudson.matrix.AxisList)1 MatrixProject (hudson.matrix.MatrixProject)1 MavenModuleSet (hudson.maven.MavenModuleSet)1 ParametersDefinitionProperty (hudson.model.ParametersDefinitionProperty)1 StringParameterDefinition (hudson.model.StringParameterDefinition)1