Search in sources :

Example 86 with DependencyMaterialConfig

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

the class PipelineConfigDependencyGraphTest method shouldFindPipelineConfigQueueEntryWithCorrespondingPath.

@Test
public void shouldFindPipelineConfigQueueEntryWithCorrespondingPath() throws Exception {
    HgMaterialConfig hgConfig = MaterialConfigsMother.hgMaterialConfig();
    PipelineConfig current = GoConfigMother.createPipelineConfigWithMaterialConfig("current", hgConfig, new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")), new DependencyMaterialConfig(new CaseInsensitiveString("up2"), new CaseInsensitiveString("first")));
    PipelineConfig up1 = GoConfigMother.createPipelineConfigWithMaterialConfig("up1", hgConfig, new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("first")));
    PipelineConfig up2 = GoConfigMother.createPipelineConfigWithMaterialConfig("up2", hgConfig, new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("first")));
    PipelineConfig uppest = GoConfigMother.createPipelineConfigWithMaterialConfig("uppest", hgConfig);
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(up1, new PipelineConfigDependencyGraph(uppest)), new PipelineConfigDependencyGraph(up2, new PipelineConfigDependencyGraph(uppest)));
    Queue<PipelineConfigDependencyGraph.PipelineConfigQueueEntry> queue = new LinkedList<>();
    queue.add(new PipelineConfigDependencyGraph.PipelineConfigQueueEntry(up1, Arrays.asList(current, up1)));
    queue.add(new PipelineConfigDependencyGraph.PipelineConfigQueueEntry(up2, Arrays.asList(current, up2)));
    queue.add(new PipelineConfigDependencyGraph.PipelineConfigQueueEntry(uppest, Arrays.asList(current, up1, uppest)));
    queue.add(new PipelineConfigDependencyGraph.PipelineConfigQueueEntry(uppest, Arrays.asList(current, up2, uppest)));
    assertThat(dependencyGraph.buildQueue(), is(queue));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) MaterialConfigsMother.filteredHgMaterialConfig(com.thoughtworks.go.helper.MaterialConfigsMother.filteredHgMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 87 with DependencyMaterialConfig

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

the class AbstractFetchTask method validateDependencies.

private void validateDependencies(ValidationContext validationContext, PipelineConfig currentPipeline) {
    DependencyMaterialConfig matchingMaterial = findMatchingDependencyMaterial(currentPipeline, pipelineName.getAncestorName());
    PipelineConfig ancestor = validationContext.getPipelineConfigByName(pipelineName.getAncestorName());
    if (matchingMaterial == null) {
        addError(PIPELINE_NAME, String.format("Pipeline \"%s\" tries to fetch artifact from pipeline " + "\"%s\" which is not an upstream pipeline", currentPipeline.name(), pipelineName));
        return;
    }
    List<StageConfig> validStages = ancestor.validStagesForFetchArtifact(currentPipeline, validationContext.getStage().name());
    if (!validStages.contains(ancestor.findBy(stage))) {
        addStageMayNotCompleteBeforeDownstreamError(currentPipeline, validationContext);
    }
}
Also used : DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)

Example 88 with DependencyMaterialConfig

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

the class AbstractFetchTask 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 89 with DependencyMaterialConfig

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

the class PipelineConfig method getDependenciesAsNode.

public Node getDependenciesAsNode() {
    List<Node.DependencyNode> pipelineDeps = new ArrayList<>();
    for (MaterialConfig material : materialConfigs) {
        if (material instanceof DependencyMaterialConfig) {
            DependencyMaterialConfig dependencyMaterialConfig = (DependencyMaterialConfig) material;
            pipelineDeps.add(new Node.DependencyNode(dependencyMaterialConfig.getPipelineName(), dependencyMaterialConfig.getStageName()));
        }
    }
    return new Node(pipelineDeps);
}
Also used : Node(com.thoughtworks.go.util.Node) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)

Example 90 with DependencyMaterialConfig

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

the class MaterialConfigs method validate.

public void validate(ValidationContext validationContext) {
    validateNameUniqueness();
    validateAutoUpdateState(validationContext);
    validateScmMaterials();
    Set<CaseInsensitiveString> dependencies = new HashSet<>();
    for (DependencyMaterialConfig material : filterDependencyMaterials()) {
        material.validateUniqueness(dependencies);
    }
    if (validationContext.isWithinPipelines()) {
        PipelineConfig currentPipeline = validationContext.getPipeline();
        validateOrigins(currentPipeline, validationContext);
    }
}
Also used : 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