Search in sources :

Example 41 with MaterialConfig

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

the class MergeCruiseConfigTest method shouldGetUniqueMaterialsWithConfigRepos.

@Test
public void shouldGetUniqueMaterialsWithConfigRepos() {
    BasicCruiseConfig mainCruiseConfig = new BasicCruiseConfig(pipelines);
    ConfigReposConfig reposConfig = new ConfigReposConfig();
    GitMaterialConfig configRepo = new GitMaterialConfig("http://git");
    reposConfig.add(new ConfigRepoConfig(configRepo, "myplug"));
    mainCruiseConfig.setConfigRepos(reposConfig);
    PartialConfig partialConfig = PartialConfigMother.withPipeline("pipe2");
    MaterialConfig pipeRepo = partialConfig.getGroups().get(0).get(0).materialConfigs().get(0);
    cruiseConfig = new BasicCruiseConfig(mainCruiseConfig, partialConfig);
    Set<MaterialConfig> materials = cruiseConfig.getAllUniqueMaterialsBelongingToAutoPipelinesAndConfigRepos();
    assertThat(materials, hasItem(configRepo));
    assertThat(materials, hasItem(pipeRepo));
    assertThat(materials.size(), is(2));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) Test(org.junit.Test)

Example 42 with MaterialConfig

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

the class MergeCruiseConfigTest method shouldGetUniqueMaterialsWithoutConfigRepos.

@Test
public void shouldGetUniqueMaterialsWithoutConfigRepos() {
    BasicCruiseConfig mainCruiseConfig = new BasicCruiseConfig(pipelines);
    ConfigReposConfig reposConfig = new ConfigReposConfig();
    GitMaterialConfig configRepo = new GitMaterialConfig("http://git");
    reposConfig.add(new ConfigRepoConfig(configRepo, "myplug"));
    mainCruiseConfig.setConfigRepos(reposConfig);
    PartialConfig partialConfig = PartialConfigMother.withPipeline("pipe2");
    MaterialConfig pipeRepo = partialConfig.getGroups().get(0).get(0).materialConfigs().get(0);
    cruiseConfig = new BasicCruiseConfig(mainCruiseConfig, partialConfig);
    Set<MaterialConfig> materials = cruiseConfig.getAllUniqueMaterialsBelongingToAutoPipelines();
    assertThat(materials, hasItem(pipeRepo));
    assertThat(materials.size(), is(1));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) Test(org.junit.Test)

Example 43 with MaterialConfig

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

the class PipelineGroups method getAllUniquePostCommitSchedulableMaterials.

public Set<MaterialConfig> getAllUniquePostCommitSchedulableMaterials() {
    Set<MaterialConfig> materialConfigs = new HashSet<>();
    Set<String> uniqueMaterials = new HashSet<>();
    for (PipelineConfigs pipelineConfigs : this) {
        for (PipelineConfig pipelineConfig : pipelineConfigs) {
            for (MaterialConfig materialConfig : pipelineConfig.materialConfigs()) {
                if ((materialConfig instanceof ScmMaterialConfig || materialConfig instanceof PluggableSCMMaterialConfig) && !materialConfig.isAutoUpdate() && !uniqueMaterials.contains(materialConfig.getFingerprint())) {
                    materialConfigs.add(materialConfig);
                    uniqueMaterials.add(materialConfig.getFingerprint());
                }
            }
        }
    }
    return materialConfigs;
}
Also used : PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)

Example 44 with MaterialConfig

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

the class ScheduledPipelineLoader method knownMaterials.

private MaterialConfigs knownMaterials(Pipeline pipeline, MaterialRevisions scheduledRevs) {
    CruiseConfig currentConfig = goConfigService.getCurrentConfig();
    MaterialConfigs configuredMaterials = new MaterialConfigs();
    for (MaterialRevision revision : scheduledRevs) {
        String fingerprint = revision.getMaterial().getFingerprint();
        // first try to find material config from current pipeline config
        MaterialConfig configuredMaterial = currentConfig.materialConfigFor(new CaseInsensitiveString(pipeline.getName()), fingerprint);
        if (configuredMaterial != null) {
            configuredMaterials.add(configuredMaterial);
            continue;
        }
        // todo: remove the global lookup fallback code after we feel safe
        if (new SystemEnvironment().get(SystemEnvironment.GO_SERVER_SCHEDULED_PIPELINE_LOADER_GLOBAL_MATERIAL_LOOKUP)) {
            // fallback to global lookup if material is not in current pipeline config (old behavior)
            configuredMaterial = currentConfig.materialConfigFor(fingerprint);
            if (configuredMaterial != null) {
                configuredMaterials.add((configuredMaterial));
            }
        }
    }
    MaterialConfigs knownMaterials = new MaterialConfigs();
    for (MaterialConfig configuredMaterial : configuredMaterials) {
        materialExpansionService.expandForScheduling(configuredMaterial, knownMaterials);
    }
    return knownMaterials;
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 45 with MaterialConfig

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

the class DependencyFanInNode method validateIfRevisionMatchesTheCurrentConfigAndUpdateTheMaterialMap.

private void validateIfRevisionMatchesTheCurrentConfigAndUpdateTheMaterialMap(FanInGraphContext context, Pair<StageIdentifier, List<FaninScmMaterial>> stageIdentifierScmPair) {
    final Set<MaterialConfig> currentScmMaterials = context.pipelineScmDepMap.get(materialConfig);
    final Set<FaninScmMaterial> scmMaterials = new HashSet<>(stageIdentifierScmPair.last());
    final Set<String> currentScmFingerprint = new HashSet<>();
    for (MaterialConfig currentScmMaterial : currentScmMaterials) {
        currentScmFingerprint.add(currentScmMaterial.getFingerprint());
    }
    final Set<String> scmMaterialsFingerprint = new HashSet<>();
    for (FaninScmMaterial scmMaterial : scmMaterials) {
        scmMaterialsFingerprint.add(scmMaterial.fingerprint);
    }
    final Collection commonMaterials = CollectionUtils.intersection(currentScmFingerprint, scmMaterialsFingerprint);
    if (commonMaterials.size() == scmMaterials.size() && commonMaterials.size() == currentScmMaterials.size()) {
        stageIdentifierScmMaterial.put(stageIdentifierScmPair.first(), scmMaterials);
        ++currentCount;
    } else {
        Collection disjunctionWithConfig = CollectionUtils.disjunction(currentScmFingerprint, commonMaterials);
        Collection disjunctionWithInstance = CollectionUtils.disjunction(scmMaterialsFingerprint, commonMaterials);
        LOGGER.warn("[Fan-in] - Incompatible materials for {}. Config: {}. Instance: {}.", stageIdentifierScmPair.first().getStageLocator(), disjunctionWithConfig, disjunctionWithInstance);
        // This is it. We will not go beyond this revision in history
        totalInstanceCount = currentCount;
    }
}
Also used : DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Aggregations

MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)133 Test (org.junit.Test)81 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)72 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)61 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)46 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)42 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 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)14 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)13 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)13 Filter (com.thoughtworks.go.config.materials.Filter)11 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)10 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)10 Material (com.thoughtworks.go.domain.materials.Material)9