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));
}
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);
}
}
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);
}
}
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);
}
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);
}
}
Aggregations