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);
}
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].");
}
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"));
}
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())));
}
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]."));
}
}
Aggregations