Search in sources :

Example 26 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig 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 27 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class BasicCruiseConfig method generatePipelineVsDownstreamMap.

@Override
public Map<String, List<PipelineConfig>> generatePipelineVsDownstreamMap() {
    List<PipelineConfig> pipelineConfigs = getAllPipelineConfigs();
    Map<String, List<PipelineConfig>> result = new HashMap<>();
    for (PipelineConfig currentPipeline : pipelineConfigs) {
        String currentPipelineName = currentPipeline.name().toString();
        if (!result.containsKey(currentPipelineName)) {
            result.put(currentPipelineName, new ArrayList<>());
        }
        for (MaterialConfig materialConfig : currentPipeline.materialConfigs()) {
            if (materialConfig instanceof DependencyMaterialConfig) {
                String pipelineWhichTriggersMe = ((DependencyMaterialConfig) materialConfig).getPipelineName().toString();
                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) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)

Example 28 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class PipelineConfig method validStagesForFetchArtifact.

public List<StageConfig> validStagesForFetchArtifact(PipelineConfig downstreamPipeline, CaseInsensitiveString currentDownstreamStage) {
    for (DependencyMaterialConfig dependencyMaterial : downstreamPipeline.dependencyMaterialConfigs()) {
        if (dependencyMaterial.getPipelineName().equals(name)) {
            List<StageConfig> stageConfigs = allStagesBefore(dependencyMaterial.getStageName());
            // add this stage itself
            stageConfigs.add(getStage(dependencyMaterial.getStageName()));
            return stageConfigs;
        }
    }
    if (this.equals(downstreamPipeline)) {
        return allStagesBefore(currentDownstreamStage);
    }
    return null;
}
Also used : DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)

Example 29 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class PipelineConfigTreeValidator method validateDependencyMaterialsForDownstreams.

private void validateDependencyMaterialsForDownstreams(PipelineConfigSaveValidationContext validationContext, CaseInsensitiveString selected, PipelineConfig downstreamPipeline) {
    Node dependenciesOfSelectedPipeline = validationContext.getDependencyMaterialsFor(selected);
    for (Node.DependencyNode dependencyNode : dependenciesOfSelectedPipeline.getDependencies()) {
        if (dependencyNode.getPipelineName().equals(pipelineConfig.name())) {
            for (MaterialConfig materialConfig : downstreamPipeline.materialConfigs()) {
                if (materialConfig instanceof DependencyMaterialConfig) {
                    DependencyMaterialConfig dependencyMaterialConfig = new Cloner().deepClone((DependencyMaterialConfig) materialConfig);
                    dependencyMaterialConfig.validate(validationContext.withParent(downstreamPipeline));
                    List<String> allErrors = dependencyMaterialConfig.errors().getAll();
                    for (String error : allErrors) {
                        pipelineConfig.errors().add("base", error);
                    }
                }
            }
        }
    }
}
Also used : DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Cloner(com.rits.cloning.Cloner)

Example 30 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class MaterialConfigs method validateOrigins.

private void validateOrigins(PipelineConfig currentPipeline, ValidationContext validationContext) {
    for (DependencyMaterialConfig material : filterDependencyMaterials()) {
        PipelineConfig upstream = validationContext.getPipelineConfigByName(material.getPipelineName());
        if (upstream == null)
            // other rule validates existence of upstream
            continue;
        ConfigOrigin myOrigin = currentPipeline.getOrigin();
        ConfigOrigin upstreamOrigin = upstream.getOrigin();
        if (validationContext.shouldCheckConfigRepo()) {
            if (!validationContext.getConfigRepos().isReferenceAllowed(myOrigin, upstreamOrigin)) {
                material.addError(DependencyMaterialConfig.ORIGIN, String.format("Dependency from pipeline defined in %s to pipeline defined in %s is not allowed", displayNameFor(myOrigin), displayNameFor(upstreamOrigin)));
            }
        }
    }
}
Also used : ConfigOrigin(com.thoughtworks.go.config.remote.ConfigOrigin) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)

Aggregations

DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)135 Test (org.junit.Test)106 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)22 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)22 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)21 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)15 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)14 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)11 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)10 Date (java.util.Date)10 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)9 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)8 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)8 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)8 Pipeline (com.thoughtworks.go.domain.Pipeline)8 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)8 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)7 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)7 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)7 ModificationsMother.changedDependencyMaterialRevision (com.thoughtworks.go.helper.ModificationsMother.changedDependencyMaterialRevision)7