Search in sources :

Example 1 with PluggableArtifactConfig

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

the class ArtifactConfigsTest method findByArtifactId_shouldReturnNullWhenPluggableArtifactConfigNotExistWithGivenId.

@Test
public void findByArtifactId_shouldReturnNullWhenPluggableArtifactConfigNotExistWithGivenId() {
    ArtifactConfigs allConfigs = new ArtifactConfigs();
    allConfigs.add(new PluggableArtifactConfig("s3", "cd.go.s3"));
    allConfigs.add(new PluggableArtifactConfig("docker", "cd.go.docker"));
    final PluggableArtifactConfig s3 = allConfigs.findByArtifactId("foo");
    assertNull(s3);
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) ArtifactConfigs(com.thoughtworks.go.config.ArtifactConfigs) Test(org.junit.Test)

Example 2 with PluggableArtifactConfig

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

the class DeleteArtifactStoreConfigCommandTest method shouldNotValidateIfArtifactStoreIsUsedInPipelineConfig.

@Test
public void shouldNotValidateIfArtifactStoreIsUsedInPipelineConfig() {
    ArtifactStore artifactStore = new ArtifactStore("foo", "cd.go.docker");
    final PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfigWithStage("up42", "up42_stage");
    pipelineConfig.getStage("up42_stage").jobConfigByConfigName("dev").artifactTypeConfigs().add(new PluggableArtifactConfig("installers", "foo"));
    cruiseConfig.addPipeline("Foo", pipelineConfig);
    DeleteArtifactStoreConfigCommand command = new DeleteArtifactStoreConfigCommand(null, artifactStore, null, null, new HttpLocalizedOperationResult());
    assertThatThrownBy(() -> command.isValid(cruiseConfig)).isInstanceOf(GoConfigInvalidException.class).hasMessageContaining("The artifact store 'foo' is being referenced by pipeline(s): JobConfigIdentifier[up42:up42_stage:dev].");
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) ArtifactStore(com.thoughtworks.go.config.ArtifactStore) GoConfigInvalidException(com.thoughtworks.go.config.exceptions.GoConfigInvalidException) Test(org.junit.jupiter.api.Test)

Example 3 with PluggableArtifactConfig

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

the class ArtifactPlanTest method shouldConvertPluggableArtifactConfigToArtifactPlans.

@Test
public void shouldConvertPluggableArtifactConfigToArtifactPlans() {
    final PluggableArtifactConfig artifactConfig = new PluggableArtifactConfig("ID", "StoreID", create("Foo", true, "Bar"), create("Baz", false, "Car"));
    final ArtifactPlan artifactPlan = new ArtifactPlan(artifactConfig);
    assertThat(artifactPlan.getArtifactPlanType(), is(ArtifactPlanType.external));
    assertThat(artifactPlan.getPluggableArtifactConfiguration().size(), is(3));
    assertThat(artifactPlan.getPluggableArtifactConfiguration(), hasEntry("id", "ID"));
    assertThat(artifactPlan.getPluggableArtifactConfiguration(), hasEntry("storeId", "StoreID"));
    final Map<String, String> configuration = (Map<String, String>) artifactPlan.getPluggableArtifactConfiguration().get("configuration");
    assertThat(configuration.size(), is(2));
    assertThat(configuration, hasEntry("Foo", "Bar"));
    assertThat(configuration, hasEntry("Baz", "Car"));
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 4 with PluggableArtifactConfig

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

the class ArtifactPlanTest method toArtifactPlans_shouldConvertArtifactConfigsToArtifactPlanList.

@Test
public void toArtifactPlans_shouldConvertArtifactConfigsToArtifactPlanList() {
    final PluggableArtifactConfig artifactConfig = new PluggableArtifactConfig("id", "storeId", create("Foo", true, "Bar"));
    final ArtifactTypeConfigs artifactTypeConfigs = new ArtifactTypeConfigs(Arrays.asList(new BuildArtifactConfig("source", "destination"), new TestArtifactConfig("test-source", "test-destination"), artifactConfig));
    final List<ArtifactPlan> artifactPlans = ArtifactPlan.toArtifactPlans(artifactTypeConfigs);
    assertThat(artifactPlans, containsInAnyOrder(new ArtifactPlan(ArtifactPlanType.file, "source", "destination"), new ArtifactPlan(ArtifactPlanType.unit, "test-source", "test-destination"), new ArtifactPlan(artifactConfig.toJSON())));
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) TestArtifactConfig(com.thoughtworks.go.config.TestArtifactConfig) BuildArtifactConfig(com.thoughtworks.go.config.BuildArtifactConfig) ArtifactTypeConfigs(com.thoughtworks.go.config.ArtifactTypeConfigs) Test(org.junit.jupiter.api.Test)

Example 5 with PluggableArtifactConfig

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

the class ArtifactsPublisherTest method shouldContinueWithOtherPluginWhenPublishArtifactCallFailsForOnePlugin.

@Test
public void shouldContinueWithOtherPluginWhenPublishArtifactCallFailsForOnePlugin() throws IOException {
    final ArtifactStore s3ArtifactStore = new ArtifactStore("s3", "cd.go.s3", create("access_key", false, "some-key"));
    final ArtifactStore dockerArtifactStore = new ArtifactStore("docker", "cd.go.docker", create("registry-url", false, "docker.io"));
    final ArtifactStores artifactStores = new ArtifactStores(s3ArtifactStore, dockerArtifactStore);
    final ArtifactPlan s3ArtifactPlan = new ArtifactPlan(new PluggableArtifactConfig("installers", "s3", create("Baz", true, "Car")));
    final ArtifactPlan dockerArtifactPlan = new ArtifactPlan(new PluggableArtifactConfig("test-reports", "docker", create("junit", false, "junit.xml")));
    when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(s3ArtifactPlan), eq(s3ArtifactStore), anyString(), eq(env))).thenThrow(new RuntimeException("Interaction with plugin `cd.go.s3` failed."));
    when(artifactExtension.publishArtifact(eq("cd.go.docker"), eq(dockerArtifactPlan), eq(dockerArtifactStore), anyString(), eq(env))).thenReturn(new PublishArtifactResponse(Collections.singletonMap("tag", "10.12.0")));
    try {
        new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(Arrays.asList(s3ArtifactPlan, dockerArtifactPlan), env);
        fail("Should throw error for pluggable artifact [installers].");
    } catch (Exception e) {
        assertThat(uploadedPluggableMetadataFiles(publisher.publishedFiles()), containsInAnyOrder("cd.go.docker.json"));
        assertThat(publisher.getMessage(), containsString("[go] Interaction with plugin `cd.go.s3` failed"));
        assertThat(e.getMessage(), containsString("[go] Uploading finished. Failed to upload [installers]."));
    }
}
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) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Aggregations

PluggableArtifactConfig (com.thoughtworks.go.config.PluggableArtifactConfig)15 Test (org.junit.jupiter.api.Test)11 ArtifactStore (com.thoughtworks.go.config.ArtifactStore)9 ArtifactStores (com.thoughtworks.go.config.ArtifactStores)7 PublishArtifactResponse (com.thoughtworks.go.plugin.access.artifact.model.PublishArtifactResponse)6 ArtifactConfigs (com.thoughtworks.go.config.ArtifactConfigs)4 Test (org.junit.Test)4 TestArtifactConfig (com.thoughtworks.go.config.TestArtifactConfig)3 ArtifactConfig (com.thoughtworks.go.config.ArtifactConfig)2 GoPublisher (com.thoughtworks.go.work.GoPublisher)2 IOException (java.io.IOException)2 InOrder (org.mockito.InOrder)2 ArtifactTypeConfigs (com.thoughtworks.go.config.ArtifactTypeConfigs)1 BuildArtifactConfig (com.thoughtworks.go.config.BuildArtifactConfig)1 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)1 ArtifactPlan (com.thoughtworks.go.domain.ArtifactPlan)1 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1