Search in sources :

Example 6 with MaterialInstance

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

the class PluggableSCMMaterialPoller method checkout.

@Override
public void checkout(PluggableSCMMaterial material, File baseDir, Revision revision, SubprocessExecutionContext execCtx) {
    SCMPropertyConfiguration scmPropertyConfiguration = buildSCMPropertyConfigurations(material.getScmConfig());
    MaterialInstance materialInstance = materialRepository.findMaterialInstance(material);
    PluggableSCMMaterialRevision pluggableSCMMaterialRevision = (PluggableSCMMaterialRevision) revision;
    SCMRevision scmRevision = new SCMRevision(pluggableSCMMaterialRevision.getRevision(), pluggableSCMMaterialRevision.getTimestamp(), null, null, pluggableSCMMaterialRevision.getData(), null);
    Result result = scmExtension.checkout(material.getPluginId(), scmPropertyConfiguration, baseDir.getAbsolutePath(), scmRevision);
    if (!result.isSuccessful())
        throw new RuntimeException("Failed to perform checkout on pluggable SCM");
}
Also used : SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) PluggableSCMMaterialRevision(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision) SCMRevision(com.thoughtworks.go.plugin.access.scm.revision.SCMRevision) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) Result(com.thoughtworks.go.plugin.api.response.Result) MaterialPollResult(com.thoughtworks.go.plugin.access.scm.material.MaterialPollResult)

Example 7 with MaterialInstance

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

the class PluggableSCMMaterialPoller method modificationsSince.

@Override
public List<Modification> modificationsSince(final PluggableSCMMaterial material, File baseDir, final Revision revision, SubprocessExecutionContext execCtx) {
    SCMPropertyConfiguration scmPropertyConfiguration = buildSCMPropertyConfigurations(material.getScmConfig());
    MaterialInstance materialInstance = materialRepository.findMaterialInstance(material);
    PluggableSCMMaterialRevision pluggableSCMMaterialRevision = (PluggableSCMMaterialRevision) revision;
    SCMRevision previouslyKnownRevision = new SCMRevision(pluggableSCMMaterialRevision.getRevision(), pluggableSCMMaterialRevision.getTimestamp(), null, null, pluggableSCMMaterialRevision.getData(), null);
    MaterialPollResult pollResult = scmExtension.latestModificationSince(material.getPluginId(), scmPropertyConfiguration, materialInstance.getAdditionalDataMap(), baseDir.getAbsolutePath(), previouslyKnownRevision);
    final Map<String, String> materialData = pollResult.getMaterialData();
    if (materialInstance.requiresUpdate(materialData)) {
        updateAdditionalData(materialInstance.getId(), materialData);
    }
    List<SCMRevision> scmRevisions = pollResult.getRevisions();
    return getModifications(scmRevisions);
}
Also used : MaterialPollResult(com.thoughtworks.go.plugin.access.scm.material.MaterialPollResult) SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) PluggableSCMMaterialRevision(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision) SCMRevision(com.thoughtworks.go.plugin.access.scm.revision.SCMRevision) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance)

Example 8 with MaterialInstance

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

the class DownstreamInstancePopulator method apply.

public void apply(ValueStreamMap valueStreamMap) {
    if (valueStreamMap.getCurrentPipeline() != null) {
        Node currentPipeline = valueStreamMap.getCurrentPipeline();
        populateRevisionsForAllChildrenOf(currentPipeline, new HashSet<>());
    } else {
        Node currentMaterial = valueStreamMap.getCurrentMaterial();
        MaterialInstance currentMaterialInstance = valueStreamMap.getCurrentMaterialInstance();
        populateRevisionsFor(currentMaterial, currentMaterialInstance, new HashSet<>());
    }
}
Also used : Node(com.thoughtworks.go.domain.valuestreammap.Node) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance)

Example 9 with MaterialInstance

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

the class GoCacheTest method get_shouldBombWhenValueIsAPersistentObjectWithoutId.

@Test
public void get_shouldBombWhenValueIsAPersistentObjectWithoutId() throws Exception {
    HgMaterial material = MaterialsMother.hgMaterial();
    MaterialInstance materialInstance = material.createMaterialInstance();
    materialInstance.setId(10);
    goCache.put("foo", materialInstance);
    materialInstance.setId(-1);
    try {
        goCache.get("foo");
        fail("should not allow getting a persistent object without id: " + materialInstance);
    } catch (Exception e) {
    // ok
    }
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) IOException(java.io.IOException) Test(org.junit.Test)

Example 10 with MaterialInstance

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

the class PackageMaterialUpdaterTest method shouldUpdateToNewMaterialInstanceWhenConfigHas_Changed.

@Test
public void shouldUpdateToNewMaterialInstanceWhenConfigHas_Changed() throws Exception {
    PackageMaterial material = MaterialsMother.packageMaterial();
    MaterialInstance materialInstance = material.createMaterialInstance();
    materialInstance.setId(1);
    material.getPackageDefinition().getConfiguration().add(ConfigurationPropertyMother.create("key2", false, "value2"));
    MaterialInstance newMaterialInstance = material.createMaterialInstance();
    newMaterialInstance.setId(1);
    File file = new File("random");
    Modifications modifications = new Modifications();
    when(materialRepository.find(anyLong())).thenReturn(materialInstance);
    materialUpdater.insertLatestOrNewModifications(material, materialInstance, file, modifications);
    verify(materialRepository).saveOrUpdate(newMaterialInstance);
    verify(scmMaterialUpdater).insertLatestOrNewModifications(material, materialInstance, file, modifications);
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) File(java.io.File) Test(org.junit.Test)

Aggregations

MaterialInstance (com.thoughtworks.go.domain.MaterialInstance)39 Test (org.junit.Test)28 File (java.io.File)13 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)10 Modification (com.thoughtworks.go.domain.materials.Modification)9 Modifications (com.thoughtworks.go.domain.materials.Modifications)9 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)7 MaterialPollResult (com.thoughtworks.go.plugin.access.scm.material.MaterialPollResult)7 SCMRevision (com.thoughtworks.go.plugin.access.scm.revision.SCMRevision)7 TransactionStatus (org.springframework.transaction.TransactionStatus)7 SCMPropertyConfiguration (com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration)6 Date (java.util.Date)6 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)5 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)5 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)5 TfsMaterial (com.thoughtworks.go.config.materials.tfs.TfsMaterial)5 TransactionCallback (org.springframework.transaction.support.TransactionCallback)5 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)4 Material (com.thoughtworks.go.domain.materials.Material)4 HashMap (java.util.HashMap)4