Search in sources :

Example 6 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class BasicCruiseConfig method getUniqueMaterials.

private Set<MaterialConfig> getUniqueMaterials(boolean ignoreManualPipelines, boolean ignoreConfigRepos) {
    Set<MaterialConfig> materialConfigs = new HashSet<>();
    Set<Map> uniqueMaterials = new HashSet<>();
    for (PipelineConfig pipelineConfig : pipelinesFromAllGroups()) {
        for (MaterialConfig materialConfig : pipelineConfig.materialConfigs()) {
            if (!uniqueMaterials.contains(materialConfig.getSqlCriteria())) {
                boolean shouldSkipPolling = !materialConfig.isAutoUpdate();
                boolean scmOrPackageMaterial = !(materialConfig instanceof DependencyMaterialConfig);
                if (ignoreManualPipelines && scmOrPackageMaterial && shouldSkipPolling) {
                    continue;
                }
                materialConfigs.add(materialConfig);
                uniqueMaterials.add(materialConfig.getSqlCriteria());
            }
        }
    }
    if (!ignoreConfigRepos) {
        for (ConfigRepoConfig configRepo : this.configRepos) {
            MaterialConfig materialConfig = configRepo.getMaterialConfig();
            if (!uniqueMaterials.contains(materialConfig.getSqlCriteria())) {
                materialConfigs.add(materialConfig);
                uniqueMaterials.add(materialConfig.getSqlCriteria());
            }
        }
    }
    return materialConfigs;
}
Also used : PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) ConcurrentMap(java.util.concurrent.ConcurrentMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)

Example 7 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class BasicCruiseConfig method materialConfigFor.

@Override
public MaterialConfig materialConfigFor(CaseInsensitiveString pipelineName, String fingerprint) {
    PipelineConfig pipelineConfig = pipelineConfigByName(pipelineName);
    MaterialConfigs materialConfigs = pipelineConfig.materialConfigs();
    for (MaterialConfig materialConfig : materialConfigs) {
        if (materialConfig.getFingerprint().equals(fingerprint)) {
            return materialConfig;
        }
    }
    return null;
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig)

Example 8 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class ConfigSaveValidationContext method primeForMaterialValidations.

private void primeForMaterialValidations() {
    CruiseConfig cruiseConfig = getCruiseConfig();
    fingerprintToMaterials = new HashMap<>();
    for (PipelineConfig pipelineConfig : cruiseConfig.getAllPipelineConfigs()) {
        for (MaterialConfig material : pipelineConfig.materialConfigs()) {
            String fingerprint = material.getFingerprint();
            if (!fingerprintToMaterials.containsKey(fingerprint)) {
                fingerprintToMaterials.put(fingerprint, new MaterialConfigs());
            }
            MaterialConfigs materialsForFingerprint = fingerprintToMaterials.get(fingerprint);
            materialsForFingerprint.add(material);
        }
    }
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig)

Example 9 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class SCMConfigXmlWriterTest method shouldAllowSCMTypeMaterialForPipeline.

@Test
public void shouldAllowSCMTypeMaterialForPipeline() throws Exception {
    CruiseConfig configToSave = new BasicCruiseConfig();
    SCM scm = new SCM();
    String scmId = "scm-id";
    scm.setId(scmId);
    scm.setName("name");
    scm.setPluginConfiguration(new PluginConfiguration("plugin-id", "1.0"));
    scm.setConfiguration(new Configuration(getConfigurationProperty("url", false, "http://go")));
    configToSave.getSCMs().add(scm);
    PluggableSCMMaterialConfig pluggableSCMMaterialConfig = new PluggableSCMMaterialConfig(scmId);
    pluggableSCMMaterialConfig.setSCMConfig(scm);
    configToSave.addPipeline("default", PipelineConfigMother.pipelineConfig("test", new MaterialConfigs(pluggableSCMMaterialConfig), new JobConfigs(new JobConfig("ls"))));
    xmlWriter.write(configToSave, output, false);
    GoConfigHolder goConfigHolder = xmlLoader.loadConfigHolder(output.toString());
    PipelineConfig pipelineConfig = goConfigHolder.config.pipelineConfigByName(new CaseInsensitiveString("test"));
    MaterialConfig materialConfig = pipelineConfig.materialConfigs().get(0);
    assertThat(materialConfig instanceof PluggableSCMMaterialConfig, is(true));
    assertThat(((PluggableSCMMaterialConfig) materialConfig).getScmId(), is(scmId));
    assertThat(((PluggableSCMMaterialConfig) materialConfig).getSCMConfig(), is(scm));
    assertThat(materialConfig.getFolder(), is(nullValue()));
    assertThat(materialConfig.filter(), is(new Filter()));
}
Also used : Filter(com.thoughtworks.go.config.materials.Filter) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) SCM(com.thoughtworks.go.domain.scm.SCM) Test(org.junit.Test)

Example 10 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class GoConfigFileHelper method addMaterialToPipeline.

public PipelineConfig addMaterialToPipeline(String pipelineName, MaterialConfig materialConfig) {
    CruiseConfig config = loadForEdit();
    PipelineConfig pipelineConfig = config.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
    for (MaterialConfig materialConfig1 : new MaterialConfig[] { materialConfig }) {
        pipelineConfig.addMaterialConfig(materialConfig1);
    }
    writeConfigFile(config);
    return pipelineConfig;
}
Also used : MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig)

Aggregations

MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)126 Test (org.junit.Test)75 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)67 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)53 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)46 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)37 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)33 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)32 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)32 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)29 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)29 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)21 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)16 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)13 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)12 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)11 Filter (com.thoughtworks.go.config.materials.Filter)11 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)10 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)9 ValueStreamMapPresentationModel (com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel)9