@Override protected ArtifactStores getPluginProfiles(CruiseConfig preprocessedConfig) { return preprocessedConfig.getArtifactStores(); }
@Override public ArtifactStores artifactStores() { return this.getCruiseConfig().getArtifactStores(); }
public ArtifactStores artifactStores() { return cruiseConfig().getArtifactStores(); }
public void encryptSecureProperties(CruiseConfig preprocessedCruiseConfig, PluggableArtifactConfig preprocessedPluggableArtifactConfig) { if (storeId != null) { ArtifactStore artifactStore = preprocessedCruiseConfig.getArtifactStores().find(preprocessedPluggableArtifactConfig.getStoreId()); encryptSecureConfigurations(artifactStore); } }
void validatePublishAndFetchExternalConfigs(PipelineTemplateConfig pipelineTemplateConfig, CruiseConfig preprocessedConfig) { List<PipelineConfig> associatedPipelineConfigs = preprocessedConfig.pipelineConfigsAssociatedWithTemplate(templateConfig.name()); for (PipelineConfig associatedPipelineConfig : associatedPipelineConfigs) { for (PluggableArtifactConfig pluggableArtifactConfig : associatedPipelineConfig.getExternalArtifactConfigs()) { externalArtifactsService.validateExternalArtifactConfig(pluggableArtifactConfig, preprocessedConfig.getArtifactStores().find(pluggableArtifactConfig.getStoreId()), true); if (!pluggableArtifactConfig.getAllErrors().isEmpty()) { pipelineTemplateConfig.addError("pipeline", String.format("Error validating publish config on associated pipeline `%s`: %s", associatedPipelineConfig.name(), pluggableArtifactConfig.getAllErrors())); } } for (FetchPluggableArtifactTask fetchPluggableArtifactTask : associatedPipelineConfig.getFetchExternalArtifactTasks()) { externalArtifactsService.validateFetchExternalArtifactTask(fetchPluggableArtifactTask, pipelineTemplateConfig, preprocessedConfig); if (!fetchPluggableArtifactTask.getAllErrors().isEmpty()) { pipelineTemplateConfig.addError("pipeline", String.format("Error validating publish config on associated pipeline `%s`: %s", associatedPipelineConfig.name(), fetchPluggableArtifactTask.getAllErrors())); } } } }
@Test public void shouldDeserializeArtifactStores() { String configXml = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'>" + "<artifactStores>\n" + " <artifactStore pluginId=\"foo\" id=\"bar\">\n" + " <property>\n" + " <key>ACCESS_KEY</key>\n" + " <value>dasdas</value>\n" + " </property>\n" + " </artifactStore>\n" + " <artifactStore pluginId=\"bar\" id=\"foo\">\n" + " <property>\n" + " <key>SECRET_ACCESS_KEY</key>\n" + " <value>$rrhsdhjf</value>\n" + " </property>\n" + " </artifactStore>\n" + "</artifactStores>" + "</cruise>"; final CruiseConfig cruiseConfig = ConfigMigrator.loadWithMigration(configXml).configForEdit; assertThat(cruiseConfig.getArtifactStores(), hasSize(2)); assertThat(cruiseConfig.getArtifactStores(), contains( new ArtifactStore("bar", "foo", create("ACCESS_KEY", false, "dasdas")), new ArtifactStore("foo", "bar", create("SECRET_ACCESS_KEY", false, "$rrhsdhjf")) )); }
private void validateFetchTasks(FetchPluggableArtifactTask preprocessedFetchPluggableArtifactTask, CruiseConfig preprocessedConfig, PluggableArtifactConfig specifiedExternalArtifact) { if (specifiedExternalArtifact != null) { ArtifactStore artifactStore = preprocessedConfig.getArtifactStores().find(specifiedExternalArtifact.getStoreId()); if (specifiedExternalArtifact.hasValidPluginAndStore(artifactStore)) { try { ValidationResult validationResult = artifactExtension.validateFetchArtifactConfig(artifactStore.getPluginId(), preprocessedFetchPluggableArtifactTask.getConfiguration().getConfigurationAsMap(true)); mapErrorsToConfiguration(validationResult, preprocessedFetchPluggableArtifactTask.getConfiguration(), preprocessedFetchPluggableArtifactTask); } catch (PluginNotFoundException e) { preprocessedFetchPluggableArtifactTask.addError("pluginId", String.format("Plugin with id `%s` is not found.", artifactStore.getPluginId())); } } else { preprocessedFetchPluggableArtifactTask.addError("pluginId", "Could not determine the plugin to perform the plugin validations. Possible reasons: artifact store does not exist or plugin is not installed."); } } }
private void encryptSecurePluginConfiguration(CruiseConfig preprocessedCruiseConfig, PluggableArtifactConfig externalArtifact) { if (externalArtifact != null) { ArtifactStore artifactStore = preprocessedCruiseConfig.getArtifactStores().find(externalArtifact.getStoreId()); if (artifactStore != null) { ArtifactPluginInfo pluginInfo = ArtifactMetadataStore.instance().getPluginInfo(artifactStore.getPluginId()); if (pluginInfo == null || pluginInfo.getFetchArtifactSettings() == null) { return; } for (ConfigurationProperty configurationProperty : getConfiguration()) { configurationProperty.handleSecureValueConfiguration(isSecure(configurationProperty.getConfigKeyName(), pluginInfo.getFetchArtifactSettings())); } } } }
@Test public void shouldWriteArtifactsConfigXMLWithType() throws Exception { CruiseConfig cruiseConfig = new BasicCruiseConfig(); cruiseConfig.getArtifactStores().add(new ArtifactStore("s3", "cd.go.artifact.docker")); final PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfigWithStage("Test", "test-stage"); final JobConfig jobConfig = pipelineConfig.getStage("test-stage").jobConfigByConfigName("dev"); jobConfig.artifactConfigs().add(new BuildArtifactConfig("build/libs/*.jar", "dist")); jobConfig.artifactConfigs().add(new TestArtifactConfig("test-result/*", "reports")); jobConfig.artifactConfigs().add(new PluggableArtifactConfig("installers", "s3")); cruiseConfig.addPipeline("TestGroup", pipelineConfig); xmlWriter.write(cruiseConfig, output, false); String actualXML = this.output.toString(); assertThat(actualXML, containsString("<artifact type=\"build\" src=\"build/libs/*.jar\" dest=\"dist\" />")); assertThat(actualXML, containsString("<artifact type=\"test\" src=\"test-result/*\" dest=\"reports\" />")); assertThat(actualXML, containsString("<artifact type=\"external\" id=\"installers\" storeId=\"s3\" />")); }
Configuration childFetchArtifactFromAncestorConfig = ((FetchPluggableArtifactTask) child.get(0).getJobs().first().tasks().get(0)).getConfiguration(); Configuration childFetchArtifactFromParentConfig = ((FetchPluggableArtifactTask) child.get(0).getJobs().first().tasks().get(1)).getConfiguration(); ArtifactStore dockerhubStore = config.getArtifactStores().first();