Search in sources :

Example 96 with MaterialRevision

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

the class MaterialChecker method updateChangedRevisions.

public void updateChangedRevisions(CaseInsensitiveString pipelineName, BuildCause buildCause) {
    for (MaterialRevision materialRevision : buildCause.getMaterialRevisions()) {
        Long latestModificationRunByPipeline = materialRepository.latestModificationRunByPipeline(pipelineName, materialRevision.getMaterial());
        Modifications revised = new Modifications();
        for (Modification modification : materialRevision.getModifications()) {
            if (modification.getId() > latestModificationRunByPipeline)
                revised.add(modification);
        }
        if (!revised.isEmpty()) {
            materialRevision.replaceModifications(revised);
            materialRevision.markAsChanged();
        } else {
            materialRevision.markAsNotChanged();
        }
    }
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 97 with MaterialRevision

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

the class MaterialRevisionBuilder method depInstance.

public Tuple depInstance(String pipelineName, int counter, Date modifiedTime, Tuple... buildCause) {
    String key = key(pipelineName, counter, modifiedTime);
    if (!instanceToRevision.containsKey(key)) {
        if (buildCause.length == 0) {
            throw new RuntimeException("Cannot create instance without a buildcause. You can retrive it without buildcause once it has been created");
        }
        DependencyMaterial material = new DependencyMaterial(new CaseInsensitiveString(pipelineName), new CaseInsensitiveString(STAGE_NAME));
        DependencyMaterialRevision revision = DependencyMaterialRevision.create(pipelineName, counter, "label", STAGE_NAME, 1);
        instanceToRevision.put(key, revision.convert(material, modifiedTime));
        final long id = getNextId();
        org.mockito.Mockito.when(pipelineDao.findPipelineByNameAndCounter(pipelineName, counter)).thenReturn(pipeline(id));
        org.mockito.Mockito.when(materialRepository.findMaterialRevisionsForPipeline(id)).thenReturn(buildCauseOfThisPipeline(buildCause));
    }
    MaterialRevision materialRevision = instanceToRevision.get(key);
    Materials materials = new Materials();
    for (MaterialRevision revision : buildCauseOfThisPipeline(buildCause)) {
        materials.add(revision.getMaterial());
    }
    PipelineConfig config = new PipelineConfig(new CaseInsensitiveString(pipelineName), materials.convertToConfigs(), new StageConfig(new CaseInsensitiveString(STAGE_NAME), new JobConfigs()));
    return new Tuple(new PipelineConfigDependencyGraph(config, dependencyGraphsFor(buildCause)), materialRevision);
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Materials(com.thoughtworks.go.config.materials.Materials) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) StageConfig(com.thoughtworks.go.config.StageConfig) PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) JobConfigs(com.thoughtworks.go.config.JobConfigs) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 98 with MaterialRevision

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

the class MaterialRevisionBuilder method insertIfNotPresent.

private void insertIfNotPresent(Material material, String key, String revision, Date modifiedTime) {
    if (!instanceToRevision.containsKey(key)) {
        Modification modification = new Modification("username", "comment", "email", modifiedTime, revision);
        instanceToRevision.put(key, new MaterialRevision(material, modification));
    }
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 99 with MaterialRevision

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

the class TestFailureSetup method setupPipelineInstnace.

private SavedStage setupPipelineInstnace(final boolean failStage, final String overriddenLabel, final List<Modification> modifications, final TestResultsStubbing test, final Date latestTransitionDate) {
    return (SavedStage) transactionTemplate.execute(new TransactionCallback() {

        public Object doInTransaction(TransactionStatus status) {
            MaterialInstance materialInstance = materialRepository.findOrCreateFrom(hgMaterial);
            for (Modification mod : modifications) {
                mod.setMaterialInstance(materialInstance);
            }
            MaterialRevision rev = new MaterialRevision(hgMaterial, modifications);
            materialRepository.saveMaterialRevision(rev);
            Pipeline pipeline = PipelineMother.schedule(pipelineConfig, BuildCause.createManualForced(new MaterialRevisions(rev), new Username(new CaseInsensitiveString("loser"))));
            if (overriddenLabel != null) {
                pipeline.setLabel(overriddenLabel);
            }
            for (JobInstance instance : pipeline.getStages().get(0).getJobInstances()) {
                for (JobStateTransition jobStateTransition : instance.getTransitions()) {
                    jobStateTransition.setStateChangeTime(latestTransitionDate);
                }
            }
            dbHelper.save(pipeline);
            Stage barStage = pipeline.getFirstStage();
            if (failStage) {
                dbHelper.failStage(barStage, latestTransitionDate);
            }
            test.stub(barStage);
            pipelineTimeline.update();
            return new SavedStage(pipeline);
        }
    });
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) JobInstance(com.thoughtworks.go.domain.JobInstance) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) TransactionStatus(org.springframework.transaction.TransactionStatus) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) JobStateTransition(com.thoughtworks.go.domain.JobStateTransition) TransactionCallback(org.springframework.transaction.support.TransactionCallback) Username(com.thoughtworks.go.server.domain.Username) Stage(com.thoughtworks.go.domain.Stage) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 100 with MaterialRevision

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

the class MaterialDatabaseDependencyUpdaterTest method shouldReturnNoNewModificationsIfNoNewPipelineHasBennCompleted.

@Test
public void shouldReturnNoNewModificationsIfNoNewPipelineHasBennCompleted() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    stubStageServiceGetHistory(null, stages(9));
    updater.updateMaterial(dependencyMaterial);
    List<Modification> modification = materialRepository.findLatestModification(dependencyMaterial).getMaterialRevision(0).getModifications();
    stubStageServiceGetHistoryAfter(dependencyMaterial, 9, stages());
    updater.updateMaterial(dependencyMaterial);
    List<Modification> newModifications = materialRepository.findModificationsSince(dependencyMaterial, new MaterialRevision(dependencyMaterial, modification));
    assertThat(newModifications.size(), is(0));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)192 Test (org.junit.Test)146 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)75 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)72 Modification (com.thoughtworks.go.domain.materials.Modification)68 Date (java.util.Date)52 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)32 Pipeline (com.thoughtworks.go.domain.Pipeline)30 Username (com.thoughtworks.go.server.domain.Username)28 PipelineMaterialRevision (com.thoughtworks.go.domain.PipelineMaterialRevision)23 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)22 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)21 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)20 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)19 PipelineDependencyNode (com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode)18 SCMDependencyNode (com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode)18 ValueStreamMap (com.thoughtworks.go.domain.valuestreammap.ValueStreamMap)18 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)17 File (java.io.File)17 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)16