Search in sources :

Example 66 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 67 with MaterialConfig

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

the class BasicCruiseConfig method generatePipelineVsDownstreamMap.

@Override
public Map<CaseInsensitiveString, List<PipelineConfig>> generatePipelineVsDownstreamMap() {
    List<PipelineConfig> pipelineConfigs = getAllPipelineConfigs();
    Map<CaseInsensitiveString, List<PipelineConfig>> result = new HashMap<>();
    for (PipelineConfig currentPipeline : pipelineConfigs) {
        CaseInsensitiveString currentPipelineName = currentPipeline.name();
        if (!result.containsKey(currentPipelineName)) {
            result.put(currentPipelineName, new ArrayList<>());
        }
        for (MaterialConfig materialConfig : currentPipeline.materialConfigs()) {
            if (materialConfig instanceof DependencyMaterialConfig) {
                CaseInsensitiveString pipelineWhichTriggersMe = ((DependencyMaterialConfig) materialConfig).getPipelineName();
                if (!result.containsKey(pipelineWhichTriggersMe)) {
                    result.put(pipelineWhichTriggersMe, new ArrayList<>());
                }
                result.get(pipelineWhichTriggersMe).add(currentPipeline);
            }
        }
    }
    return result;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) 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) Collectors.toList(java.util.stream.Collectors.toList) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)

Example 68 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)

Example 69 with MaterialConfig

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

the class FanInGraph method createFinalRevisionsForScmChildren.

private List<MaterialRevision> createFinalRevisionsForScmChildren(PipelineTimelineEntry latestRootNodeInstance, List<RootFanInNode> scmChildren, List<DependencyFanInNode> depChildren) {
    Set<FaninScmMaterial> scmMaterialsFromDepChildren = scmMaterialsOfDepChildren(depChildren);
    List<MaterialRevision> finalRevisions = new ArrayList<>();
    for (RootFanInNode child : scmChildren) {
        child.setScmRevision(scmMaterialsFromDepChildren);
        MaterialConfig materialConfig = child.materialConfig;
        Material material = materialConfigConverter.toMaterial(materialConfig);
        MaterialRevision revision = new MaterialRevision(material);
        if (latestRootNodeInstance != null) {
            PipelineInstanceModel pipeline = pipelineDao.findPipelineHistoryByNameAndCounter(latestRootNodeInstance.getPipelineName(), latestRootNodeInstance.getCounter());
            for (MaterialRevision materialRevision : pipeline.getCurrentRevisions()) {
                if (materialRevision.getMaterial().getFingerprint().equals(child.materialConfig.getFingerprint())) {
                    List<Modification> modificationsSince = materialRepository.findModificationsSinceAndUptil(material, materialRevision, child.scmRevision);
                    revision.addModifications(modificationsSince);
                    break;
                }
            }
        }
        if (revision.getModifications().isEmpty() && child.scmRevision == null) {
            MaterialRevisions latestRevisions = materialRepository.findLatestRevisions(new MaterialConfigs(materialConfig));
            finalRevisions.addAll(latestRevisions.getRevisions());
            continue;
        }
        if (revision.getModifications().isEmpty()) {
            revision = new MaterialRevision(material, materialRepository.findModificationWithRevision(material, child.scmRevision.revision));
        }
        finalRevisions.add(revision);
    }
    return finalRevisions;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Material(com.thoughtworks.go.domain.materials.Material) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 70 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)

Aggregations

MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)171 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)90 Test (org.junit.jupiter.api.Test)86 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)74 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)64 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)48 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)44 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)42 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)42 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)39 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)36 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)20 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)19 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)19 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)18 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)17 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)13 Material (com.thoughtworks.go.domain.materials.Material)13 Modification (com.thoughtworks.go.domain.materials.Modification)13 Test (org.junit.Test)12