Search in sources :

Example 6 with ArtifactStores

use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.

the class ArtifactsPublisherTest method shouldDeletePluggableArtifactMetadataDirectory.

@Test
public void shouldDeletePluggableArtifactMetadataDirectory() throws Exception {
    TestFileUtil.createTestFile(workingFolder, "installer.zip");
    TestFileUtil.createTestFile(workingFolder, "testreports.xml");
    final ArtifactStore artifactStore = new ArtifactStore("s3", "cd.go.s3", create("Foo", false, "Bar"));
    final ArtifactStores artifactStores = new ArtifactStores(artifactStore);
    final ArtifactPlan artifactPlan = new ArtifactPlan(new PluggableArtifactConfig("installers", "s3", create("Baz", true, "Car")));
    List<ArtifactPlan> artifactPlans = Arrays.asList(new ArtifactPlan(ArtifactPlanType.file, "installer.zip", "dist"), new ArtifactPlan(ArtifactPlanType.unit, "testreports.xml", "testreports"), artifactPlan);
    when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(artifactPlan), eq(artifactStore), anyString(), eq(env))).thenReturn(new PublishArtifactResponse(Collections.singletonMap("Foo", "Bar")));
    final GoPublisher publisher = mock(GoPublisher.class);
    assertThat(Arrays.asList(workingFolder.list()), containsInAnyOrder("testreports.xml", "installer.zip", "cruise-output"));
    new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(artifactPlans, env);
    assertThat(Arrays.asList(workingFolder.list()), containsInAnyOrder("testreports.xml", "installer.zip", "cruise-output"));
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) ArtifactStores(com.thoughtworks.go.config.ArtifactStores) ArtifactStore(com.thoughtworks.go.config.ArtifactStore) PublishArtifactResponse(com.thoughtworks.go.plugin.access.artifact.model.PublishArtifactResponse) GoPublisher(com.thoughtworks.go.work.GoPublisher) Test(org.junit.jupiter.api.Test)

Example 7 with ArtifactStores

use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.

the class ArtifactsPublisherTest method shouldUploadFilesCorrectly.

@Test
public void shouldUploadFilesCorrectly() throws Exception {
    List<ArtifactPlan> artifactPlans = new ArrayList<>();
    final File src1 = TestFileUtil.createTestFolder(workingFolder, "src1");
    TestFileUtil.createTestFile(src1, "test.txt");
    artifactPlans.add(new ArtifactPlan(ArtifactPlanType.file, src1.getName(), "dest"));
    final File src2 = TestFileUtil.createTestFolder(workingFolder, "src2");
    TestFileUtil.createTestFile(src1, "test.txt");
    artifactPlans.add(new ArtifactPlan(ArtifactPlanType.file, src2.getName(), "test"));
    StubGoPublisher publisher = new StubGoPublisher();
    new ArtifactsPublisher(publisher, artifactExtension, new ArtifactStores(), registry, workingFolder).publishArtifacts(artifactPlans, env);
    Map<File, String> expectedFiles = new HashMap<File, String>() {

        {
            put(src1, "dest");
            put(src2, "test");
        }
    };
    assertThat(publisher.publishedFiles(), is(expectedFiles));
}
Also used : ArtifactStores(com.thoughtworks.go.config.ArtifactStores) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 8 with ArtifactStores

use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.

the class ArtifactsPublisherTest method shouldAddPluggableArtifactMetadataFileArtifactPlanAtTop.

@Test
public void shouldAddPluggableArtifactMetadataFileArtifactPlanAtTop() throws Exception {
    TestFileUtil.createTestFile(workingFolder, "installer.zip");
    TestFileUtil.createTestFile(workingFolder, "testreports.xml");
    final ArtifactStore artifactStore = new ArtifactStore("s3", "cd.go.s3", create("Foo", false, "Bar"));
    final ArtifactStores artifactStores = new ArtifactStores(artifactStore);
    final ArtifactPlan artifactPlan = new ArtifactPlan(new PluggableArtifactConfig("installers", "s3", create("Baz", true, "Car")));
    List<ArtifactPlan> artifactPlans = Arrays.asList(new ArtifactPlan(ArtifactPlanType.file, "installer.zip", "dist"), new ArtifactPlan(ArtifactPlanType.unit, "testreports.xml", "testreports"), artifactPlan);
    when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(artifactPlan), eq(artifactStore), anyString(), eq(env))).thenReturn(new PublishArtifactResponse(Collections.singletonMap("Foo", "Bar")));
    final GoPublisher publisher = mock(GoPublisher.class);
    new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(artifactPlans, env);
    InOrder inOrder = inOrder(publisher);
    inOrder.verify(publisher).upload(any(), eq("pluggable-artifact-metadata"));
    inOrder.verify(publisher).upload(any(), eq("dist"));
    inOrder.verify(publisher).upload(any(), eq("testreports"));
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) ArtifactStores(com.thoughtworks.go.config.ArtifactStores) InOrder(org.mockito.InOrder) ArtifactStore(com.thoughtworks.go.config.ArtifactStore) PublishArtifactResponse(com.thoughtworks.go.plugin.access.artifact.model.PublishArtifactResponse) GoPublisher(com.thoughtworks.go.work.GoPublisher) Test(org.junit.jupiter.api.Test)

Example 9 with ArtifactStores

use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.

the class BuildWorkEnvironmentVariablesTest method getBuildWorkWithP4MaterialRevision.

private BuildWork getBuildWorkWithP4MaterialRevision(P4Material p4Material) {
    pipelineConfig.setMaterialConfigs(new Materials(p4Material).convertToConfigs());
    JobPlan plan = new DefaultJobPlan(new Resources(), new ArrayList<>(), new ArrayList<>(), -1, new JobIdentifier(PIPELINE_NAME, 1, "1", STAGE_NAME, "1", JOB_NAME, 123L), null, new EnvironmentVariables(), new EnvironmentVariables(), null);
    MaterialRevisions materialRevisions = new MaterialRevisions(new MaterialRevision(p4Material, new Modification("user", "comment", "a@b.com", new Date(), "10")));
    BuildCause buildCause = BuildCause.createWithModifications(materialRevisions, TRIGGERED_BY_USER);
    List<Builder> builders = new ArrayList<>();
    builders.add(new CommandBuilder("ant", "", dir, new RunIfConfigs(), new NullBuilder(), ""));
    BuildAssignment assignment = BuildAssignment.create(plan, buildCause, builders, dir, environmentVariableContext, new ArtifactStores());
    return new BuildWork(assignment, systemEnvironment.consoleLogCharset());
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ArtifactStores(com.thoughtworks.go.config.ArtifactStores) Materials(com.thoughtworks.go.config.materials.Materials) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) Builder(com.thoughtworks.go.domain.builder.Builder) NullBuilder(com.thoughtworks.go.domain.builder.NullBuilder) ArrayList(java.util.ArrayList) NullBuilder(com.thoughtworks.go.domain.builder.NullBuilder) Date(java.util.Date) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder)

Example 10 with ArtifactStores

use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.

the class BuildAssignmentTest method shouldInitializeEnvironmentContextFromJobPlanWithTriggerVariablesOverridingEnvVariablesFromJob.

@Test
void shouldInitializeEnvironmentContextFromJobPlanWithTriggerVariablesOverridingEnvVariablesFromJob() {
    DefaultJobPlan defaultJobPlan = jobForPipeline("foo");
    EnvironmentVariables triggerVariables = new EnvironmentVariables();
    triggerVariables.add("key1", "override");
    triggerVariables.add("key3", "value3");
    EnvironmentVariables variables = new EnvironmentVariables();
    variables.add("key1", "value1");
    variables.add("key2", "value2");
    defaultJobPlan.setTriggerVariables(triggerVariables);
    defaultJobPlan.setVariables(variables);
    BuildAssignment buildAssignment = BuildAssignment.create(defaultJobPlan, BuildCause.createManualForced(), new ArrayList<>(), null, null, new ArtifactStores());
    EnvironmentVariableContext context = buildAssignment.initialEnvironmentVariableContext();
    assertThat(context.getProperties().size()).isEqualTo(9);
    assertThat(context.getProperty("key1")).isEqualTo("override");
    assertThat(context.getProperty("key2")).isEqualTo("value2");
}
Also used : ArtifactStores(com.thoughtworks.go.config.ArtifactStores) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.jupiter.api.Test)

Aggregations

ArtifactStores (com.thoughtworks.go.config.ArtifactStores)23 Test (org.junit.jupiter.api.Test)15 ArtifactStore (com.thoughtworks.go.config.ArtifactStore)10 PluggableArtifactConfig (com.thoughtworks.go.config.PluggableArtifactConfig)7 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)7 PublishArtifactResponse (com.thoughtworks.go.plugin.access.artifact.model.PublishArtifactResponse)6 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)6 Builder (com.thoughtworks.go.domain.builder.Builder)4 NullBuilder (com.thoughtworks.go.domain.builder.NullBuilder)4 File (java.io.File)4 ArrayList (java.util.ArrayList)4 CommandBuilder (com.thoughtworks.go.domain.builder.CommandBuilder)3 Modification (com.thoughtworks.go.domain.materials.Modification)3 IOException (java.io.IOException)3 Materials (com.thoughtworks.go.config.materials.Materials)2 BuildAssignment (com.thoughtworks.go.remote.work.BuildAssignment)2 BuildWork (com.thoughtworks.go.remote.work.BuildWork)2 GoPublisher (com.thoughtworks.go.work.GoPublisher)2 InOrder (org.mockito.InOrder)2 Gson (com.google.gson.Gson)1