Search in sources :

Example 6 with DependencyMaterialConfig

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

the class PipelineConfigValidationTest method shouldAllowDependenciesFromMultiplePipelinesToTheSamePipeline.

@Test
public void shouldAllowDependenciesFromMultiplePipelinesToTheSamePipeline() throws Exception {
    pipeline.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("pipeline2"), new CaseInsensitiveString("stage")));
    PipelineConfig pipeline3 = config.pipelineConfigByName(new CaseInsensitiveString("pipeline3"));
    pipeline3.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("pipeline2"), new CaseInsensitiveString("stage")));
    pipeline.validate(validationContext);
    assertThat(pipeline.errors().isEmpty(), is(true));
    pipeline3.validate(validationContext);
    assertThat(pipeline3.errors().isEmpty(), is(true));
}
Also used : DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 7 with DependencyMaterialConfig

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

the class FetchTask method validatePathFromAncestor.

private void validatePathFromAncestor(PipelineConfig currentPipeline, ValidationContext validationContext) {
    List<CaseInsensitiveString> parentPipelineNames = pipelineName.pathIncludingAncestor();
    PipelineConfig pipeline = currentPipeline;
    CaseInsensitiveString dependencyStage = null;
    for (CaseInsensitiveString parentPipelineName : parentPipelineNames) {
        if (validationContext.getPipelineConfigByName(parentPipelineName) == null) {
            addError(FetchTask.PIPELINE_NAME, String.format("Pipeline named '%s' which is declared ancestor of '%s' through path '%s' does not exist.", parentPipelineName, currentPipeline.name(), pipelineName.getPath()));
            return;
        }
        DependencyMaterialConfig matchingDependencyMaterial = findMatchingDependencyMaterial(pipeline, parentPipelineName);
        if (matchingDependencyMaterial != null) {
            dependencyStage = matchingDependencyMaterial.getStageName();
            pipeline = validationContext.getPipelineConfigByName(matchingDependencyMaterial.getPipelineName());
        } else {
            addError(FetchTask.PIPELINE_NAME, String.format("Pipeline named '%s' exists, but is not an ancestor of '%s' as declared in '%s'.", parentPipelineName, currentPipeline.name(), pipelineName.getPath()));
            return;
        }
    }
    boolean foundStageAtOrBeforeDependency = dependencyStage.equals(stage);
    if (!foundStageAtOrBeforeDependency) {
        for (StageConfig stageConfig : pipeline.allStagesBefore(dependencyStage)) {
            foundStageAtOrBeforeDependency = stage.equals(stageConfig.name());
            if (foundStageAtOrBeforeDependency) {
                break;
            }
        }
    }
    if (!foundStageAtOrBeforeDependency) {
        addStageMayNotCompleteBeforeDownstreamError(currentPipeline, validationContext);
    }
}
Also used : DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)

Example 8 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 9 with DependencyMaterialConfig

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

the class BasicCruiseConfig method getStagesUsedAsMaterials.

@Override
public Set<StageConfig> getStagesUsedAsMaterials(PipelineConfig pipelineConfig) {
    Set<String> stagesUsedAsMaterials = new HashSet<>();
    for (MaterialConfig materialConfig : getAllUniqueMaterials()) {
        if (materialConfig instanceof DependencyMaterialConfig) {
            DependencyMaterialConfig dep = (DependencyMaterialConfig) materialConfig;
            stagesUsedAsMaterials.add(dep.getPipelineName() + "|" + dep.getStageName());
        }
    }
    Set<StageConfig> stages = new HashSet<>();
    for (StageConfig stage : pipelineConfig) {
        if (stagesUsedAsMaterials.contains(pipelineConfig.name() + "|" + stage.name())) {
            stages.add(stage);
        }
    }
    return stages;
}
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) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)

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

Aggregations

DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)131 Test (org.junit.Test)83 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)23 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)22 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)22 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)17 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)13 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