use of com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision in project gocd by gocd.
the class DependencyMaterial method populateEnvironmentContext.
public void populateEnvironmentContext(EnvironmentVariableContext context, MaterialRevision materialRevision, File workingDir) {
DependencyMaterialRevision revision = (DependencyMaterialRevision) materialRevision.getRevision();
context.setPropertyWithEscape(format("GO_DEPENDENCY_LABEL_%s", getName()), revision.getPipelineLabel());
context.setPropertyWithEscape(format("GO_DEPENDENCY_LOCATOR_%s", getName()), revision.getRevision());
}
use of com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision in project gocd by gocd.
the class ValueStreamMapService method traverseUpstream.
private void traverseUpstream(String pipelineName, BuildCause buildCause, ValueStreamMap graph, List<MaterialRevision> visitedNodes) {
for (MaterialRevision materialRevision : buildCause.getMaterialRevisions()) {
Material material = materialRevision.getMaterial();
if (material instanceof DependencyMaterial) {
String upstreamPipeline = ((DependencyMaterial) material).getPipelineName().toString();
DependencyMaterialRevision revision = (DependencyMaterialRevision) materialRevision.getRevision();
graph.addUpstreamNode(new PipelineDependencyNode(upstreamPipeline, upstreamPipeline), new PipelineRevision(revision.getPipelineName(), revision.getPipelineCounter(), revision.getPipelineLabel()), pipelineName);
if (visitedNodes.contains(materialRevision)) {
continue;
}
visitedNodes.add(materialRevision);
DependencyMaterialRevision dmrOfUpstreamPipeline = buildCause.getMaterialRevisions().findDependencyMaterialRevision(upstreamPipeline);
BuildCause buildCauseForUpstreamPipeline = pipelineService.buildCauseFor(dmrOfUpstreamPipeline.getPipelineName(), dmrOfUpstreamPipeline.getPipelineCounter());
traverseUpstream(upstreamPipeline, buildCauseForUpstreamPipeline, graph, visitedNodes);
} else {
graph.addUpstreamMaterialNode(new SCMDependencyNode(material.getFingerprint(), material.getUriForDisplay(), materialRevision.getMaterialType()), material.getName(), pipelineName, materialRevision);
}
}
}
use of com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision in project gocd by gocd.
the class PipelineService method populateRevisionsUsingUpstream.
private void populateRevisionsUsingUpstream(MaterialRevisions actualRevisions, MaterialRevisions newRevisions, DependencyMaterialRevision dmr, PipelineConfigDependencyGraph.PipelineConfigQueueEntry configQueueEntry) {
if (!configQueueEntry.containsPipelineInPath(dmr.getPipelineName())) {
return;
}
for (MaterialRevision materialRevision : actualRevisions) {
Material material = materialRevision.getMaterial();
if (currentPipelineHasMaterial(configQueueEntry, material) && !alreadyAdded(newRevisions, material)) {
List<PipelineConfig> paths = removePathHead(configQueueEntry);
if (!paths.isEmpty()) {
MaterialRevision revision = getRevisionFor(paths, dmr, material);
// revision is null when an upstream is both parent and grandparent
if (revision != null) {
materialRevision.replaceModifications(revision.getModifications());
newRevisions.addRevision(materialRevision);
}
}
}
}
}
use of com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision in project gocd by gocd.
the class FetchTaskTest method buildCauseWithDependencyMaterial.
private BuildCause buildCauseWithDependencyMaterial(String upstreamPipelineName, int upstreamPipelineCounter, String upstreamPipelineLabel, String upstreamStageName, int upstreamStageCounter) {
BuildCause buildCause = BuildCause.createWithEmptyModifications();
MaterialRevisions materialRevisions = new MaterialRevisions();
DependencyMaterialRevision materialRevision = DependencyMaterialRevision.create(upstreamPipelineName, upstreamPipelineCounter, upstreamPipelineLabel, upstreamStageName, upstreamStageCounter);
MaterialRevision withRevision = materialRevision.convert(new DependencyMaterial(new CaseInsensitiveString(upstreamPipelineName), new CaseInsensitiveString(upstreamStageName)), new Date());
materialRevisions.addRevision(withRevision);
buildCause.setMaterialRevisions(materialRevisions);
return buildCause;
}
use of com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision in project gocd by gocd.
the class EnvironmentVariableContextTest method materialRevision.
private MaterialRevision materialRevision(String materialName, String pipelineName, Integer pipelineCounter, String pipelineLabel, String stageName, int stageCounter) {
DependencyMaterial material = new DependencyMaterial(new CaseInsensitiveString(pipelineName), new CaseInsensitiveString(stageName));
if (!StringUtils.isEmpty(materialName)) {
material.setName(new CaseInsensitiveString(materialName));
}
DependencyMaterialRevision revision = DependencyMaterialRevision.create(pipelineName, pipelineCounter, pipelineLabel, stageName, stageCounter);
MaterialRevision materialRevision = revision.convert(material, new Date());
return materialRevision;
}
Aggregations