Search in sources :

Example 36 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.

the class DownstreamInstancePopulatorIntegrationTest method shouldPopulateMultipleInstancesBuiltFromUpstreamRevisions.

@Test
public void shouldPopulateMultipleInstancesBuiltFromUpstreamRevisions() {
    /*
            g1 -> P -> P2  -->  P4 --> P5
                        \      /
                         + P3 +
        */
    ValueStreamMap valueStreamMap = new ValueStreamMap("p", new PipelineRevision("p", 1, "13.1.1"));
    Node nodep2 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p2", "p2"), "p");
    Node nodep3 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p3", "p3"), "p2");
    Node nodep4 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p4", "p4"), "p3");
    valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p4", "p4"), "p2");
    valueStreamMap.addUpstreamMaterialNode(new SCMDependencyNode("g1", "g1", "git"), new CaseInsensitiveString("git"), "p", new MaterialRevision(null));
    GitMaterial g1 = u.wf(new GitMaterial("g1"), "folder3");
    u.checkinInOrder(g1, "g_1");
    ScheduleTestUtil.AddedPipeline p = u.saveConfigWith("p", u.m(g1));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(p2));
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(p2), u.m(p3));
    String p_1 = u.runAndPass(p, "g_1");
    String p2_1 = u.runAndPass(p2, p_1);
    String p2_2 = u.runAndPass(p2, p_1);
    String p3_1 = u.runAndPass(p3, p2_2);
    String p4_1 = u.runAndPass(p4, p2_1, p3_1);
    String p4_2 = u.runAndPass(p4, p2_2, p3_1);
    downstreamInstancePopulator.apply(valueStreamMap);
    assertInstances(nodep2, "p2", 1, 2);
    assertInstances(nodep3, "p3", 1);
    assertInstances(nodep4, "p4", 1, 2);
}
Also used : ValueStreamMap(com.thoughtworks.go.domain.valuestreammap.ValueStreamMap) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) PipelineRevision(com.thoughtworks.go.domain.valuestreammap.PipelineRevision) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) Node(com.thoughtworks.go.domain.valuestreammap.Node) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) ScheduleTestUtil(com.thoughtworks.go.server.service.ScheduleTestUtil) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 37 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.

the class PipelineInstanceModelTest method shouldGetLatestMaterialRevisionForMaterial.

@Test
public void shouldGetLatestMaterialRevisionForMaterial() {
    HgMaterial material = MaterialsMother.hgMaterial();
    assertThat(setUpModificationForHgMaterial().getLatestMaterialRevision(material.config()), is(new MaterialRevision(material, HG_MATERIAL_MODIFICATION)));
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Example 38 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.

the class EnvironmentVariableContextTest method shouldPopulateEnvironmentForMaterialUsingDest.

@Test
public void shouldPopulateEnvironmentForMaterialUsingDest() throws IOException {
    SvnMaterial svn = MaterialsMother.svnMaterial();
    svn.setFolder("svn-dir");
    MaterialRevision revision = new MaterialRevision(svn, ModificationsMother.oneModifiedFile("revision1"));
    MaterialRevisions materialRevisions = new MaterialRevisions(revision);
    EnvironmentVariableContext context = new EnvironmentVariableContext();
    context.setProperty("GO_SERVER_URL", SystemEnvironment.getProperty("serviceUrl"), false);
    jobIdentifier().populateEnvironmentVariables(context);
    materialRevisions.populateEnvironmentVariables(context, temporaryFolder.newFolder());
    assertThat(context.getProperty("GO_REVISION_SVN_DIR"), is("revision1"));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.Test)

Example 39 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.

the class ScheduledPipelineLoader method knownMaterials.

private MaterialConfigs knownMaterials(Pipeline pipeline, MaterialRevisions scheduledRevs) {
    CruiseConfig currentConfig = goConfigService.getCurrentConfig();
    MaterialConfigs configuredMaterials = new MaterialConfigs();
    for (MaterialRevision revision : scheduledRevs) {
        String fingerprint = revision.getMaterial().getFingerprint();
        // first try to find material config from current pipeline config
        MaterialConfig configuredMaterial = currentConfig.materialConfigFor(new CaseInsensitiveString(pipeline.getName()), fingerprint);
        if (configuredMaterial != null) {
            configuredMaterials.add(configuredMaterial);
            continue;
        }
        // todo: remove the global lookup fallback code after we feel safe
        if (new SystemEnvironment().get(SystemEnvironment.GO_SERVER_SCHEDULED_PIPELINE_LOADER_GLOBAL_MATERIAL_LOOKUP)) {
            // fallback to global lookup if material is not in current pipeline config (old behavior)
            configuredMaterial = currentConfig.materialConfigFor(fingerprint);
            if (configuredMaterial != null) {
                configuredMaterials.add((configuredMaterial));
            }
        }
    }
    MaterialConfigs knownMaterials = new MaterialConfigs();
    for (MaterialConfig configuredMaterial : configuredMaterials) {
        materialExpansionService.expandForScheduling(configuredMaterial, knownMaterials);
    }
    return knownMaterials;
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 40 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision 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);
        }
    }
}
Also used : Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Aggregations

MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)185 Test (org.junit.Test)141 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)72 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)68 Modification (com.thoughtworks.go.domain.materials.Modification)65 Date (java.util.Date)50 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)31 Pipeline (com.thoughtworks.go.domain.Pipeline)29 Username (com.thoughtworks.go.server.domain.Username)27 PipelineMaterialRevision (com.thoughtworks.go.domain.PipelineMaterialRevision)23 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)21 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)21 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)20 PipelineDependencyNode (com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode)18 SCMDependencyNode (com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode)18 ValueStreamMap (com.thoughtworks.go.domain.valuestreammap.ValueStreamMap)18 File (java.io.File)17 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)16 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)16 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)16