Search in sources :

Example 16 with SCMRevision

use of com.thoughtworks.go.plugin.access.scm.revision.SCMRevision in project gocd by gocd.

the class PluggableSCMMaterialAgent method prepare.

@Override
public void prepare() {
    PluggableSCMMaterial material = (PluggableSCMMaterial) revision.getMaterial();
    Modification latestModification = revision.getLatestModification();
    SCMRevision scmRevision = new SCMRevision(latestModification.getRevision(), latestModification.getModifiedTime(), null, null, latestModification.getAdditionalDataMap(), null);
    File destinationFolder = material.workingDirectory(workingDirectory);
    Result result = scmExtension.checkout(material.getScmConfig().getPluginConfiguration().getId(), buildSCMPropertyConfigurations(material.getScmConfig()), destinationFolder.getAbsolutePath(), scmRevision);
    if (!result.isSuccessful()) {
    // handle
    }
// handle messages
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) SCMRevision(com.thoughtworks.go.plugin.access.scm.revision.SCMRevision) File(java.io.File) Result(com.thoughtworks.go.plugin.api.response.Result)

Example 17 with SCMRevision

use of com.thoughtworks.go.plugin.access.scm.revision.SCMRevision in project gocd by gocd.

the class JsonMessageHandler1_0Test method shouldBuildRequestBodyForLatestRevisionsSinceRequest.

@Test
public void shouldBuildRequestBodyForLatestRevisionsSinceRequest() throws Exception {
    Date timestamp = new SimpleDateFormat(DATE_FORMAT).parse("2011-07-13T19:43:37.100Z");
    Map data = new LinkedHashMap();
    data.put("dataKeyOne", "data-value-one");
    data.put("dataKeyTwo", "data-value-two");
    SCMRevision previouslyKnownRevision = new SCMRevision("abc.rpm", timestamp, "someuser", "comment", data, null);
    String requestBody = messageHandler.requestMessageForLatestRevisionsSince(scmPropertyConfiguration, materialData, "flyweight", previouslyKnownRevision);
    String expectedValue = "{\"scm-configuration\":{\"key-one\":{\"value\":\"value-one\"},\"key-two\":{\"value\":\"value-two\"}},\"scm-data\":{\"key-one\":\"value-one\"},\"flyweight-folder\":\"flyweight\"," + "\"previous-revision\":{\"revision\":\"abc.rpm\",\"timestamp\":\"2011-07-13T19:43:37.100Z\",\"data\":{\"dataKeyOne\":\"data-value-one\",\"dataKeyTwo\":\"data-value-two\"}}}";
    assertThat(requestBody, is(expectedValue));
}
Also used : SCMRevision(com.thoughtworks.go.plugin.access.scm.revision.SCMRevision) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 18 with SCMRevision

use of com.thoughtworks.go.plugin.access.scm.revision.SCMRevision in project gocd by gocd.

the class JsonMessageHandler1_0Test method shouldBuildRequestBodyForCheckoutRequest.

@Test
public void shouldBuildRequestBodyForCheckoutRequest() throws Exception {
    Date timestamp = new SimpleDateFormat(DATE_FORMAT).parse("2011-07-13T19:43:37.100Z");
    Map data = new LinkedHashMap();
    data.put("dataKeyOne", "data-value-one");
    data.put("dataKeyTwo", "data-value-two");
    SCMRevision revision = new SCMRevision("abc.rpm", timestamp, "someuser", "comment", data, null);
    String requestBody = messageHandler.requestMessageForCheckout(scmPropertyConfiguration, "destination", revision);
    String expectedValue = "{\"scm-configuration\":{\"key-one\":{\"value\":\"value-one\"},\"key-two\":{\"value\":\"value-two\"}},\"destination-folder\":\"destination\"," + "\"revision\":{\"revision\":\"abc.rpm\",\"timestamp\":\"2011-07-13T19:43:37.100Z\",\"data\":{\"dataKeyOne\":\"data-value-one\",\"dataKeyTwo\":\"data-value-two\"}}}";
    assertThat(requestBody, is(expectedValue));
}
Also used : SCMRevision(com.thoughtworks.go.plugin.access.scm.revision.SCMRevision) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 19 with SCMRevision

use of com.thoughtworks.go.plugin.access.scm.revision.SCMRevision in project gocd by gocd.

the class PluggableSCMMaterialPoller method latestModification.

@Override
public List<Modification> latestModification(final PluggableSCMMaterial material, File baseDir, SubprocessExecutionContext execCtx) {
    SCMPropertyConfiguration scmPropertyConfiguration = buildSCMPropertyConfigurations(material.getScmConfig());
    final MaterialInstance materialInstance = materialRepository.findMaterialInstance(material);
    MaterialPollResult pollResult = scmExtension.getLatestRevision(material.getPluginId(), scmPropertyConfiguration, materialInstance.getAdditionalDataMap(), baseDir.getAbsolutePath());
    final Map<String, String> materialData = pollResult.getMaterialData();
    if (materialInstance.requiresUpdate(materialData)) {
        updateAdditionalData(materialInstance.getId(), materialData);
    }
    SCMRevision scmRevision = pollResult.getLatestRevision();
    return scmRevision == null ? new Modifications() : new Modifications(getModification(scmRevision));
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) MaterialPollResult(com.thoughtworks.go.plugin.access.scm.material.MaterialPollResult) SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) SCMRevision(com.thoughtworks.go.plugin.access.scm.revision.SCMRevision) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance)

Example 20 with SCMRevision

use of com.thoughtworks.go.plugin.access.scm.revision.SCMRevision in project gocd by gocd.

the class MaterialServiceTest method shouldGetLatestModification_PluggableSCMMaterial.

@Test
public void shouldGetLatestModification_PluggableSCMMaterial() {
    PluggableSCMMaterial pluggableSCMMaterial = MaterialsMother.pluggableSCMMaterial();
    MaterialInstance materialInstance = pluggableSCMMaterial.createMaterialInstance();
    when(materialRepository.findMaterialInstance(any(Material.class))).thenReturn(materialInstance);
    MaterialPollResult materialPollResult = new MaterialPollResult(null, new SCMRevision("blah-123", new Date(), "user", "comment", null, null));
    when(scmExtension.getLatestRevision(any(String.class), any(SCMPropertyConfiguration.class), any(Map.class), any(String.class))).thenReturn(materialPollResult);
    List<Modification> modifications = materialService.latestModification(pluggableSCMMaterial, new File("/tmp/flyweight"), null);
    assertThat(modifications.get(0).getRevision(), is("blah-123"));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) MaterialPollResult(com.thoughtworks.go.plugin.access.scm.material.MaterialPollResult) SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) SCMRevision(com.thoughtworks.go.plugin.access.scm.revision.SCMRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) GitMaterialInstance(com.thoughtworks.go.domain.materials.git.GitMaterialInstance) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) Map(java.util.Map) File(java.io.File) Date(java.util.Date) Test(org.junit.Test)

Aggregations

SCMRevision (com.thoughtworks.go.plugin.access.scm.revision.SCMRevision)22 Test (org.junit.Test)16 MaterialPollResult (com.thoughtworks.go.plugin.access.scm.material.MaterialPollResult)15 File (java.io.File)10 MaterialInstance (com.thoughtworks.go.domain.MaterialInstance)7 Modification (com.thoughtworks.go.domain.materials.Modification)7 ModifiedFile (com.thoughtworks.go.plugin.access.scm.revision.ModifiedFile)7 PluggableSCMMaterialRevision (com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision)6 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)5 SCMPropertyConfiguration (com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration)5 Date (java.util.Date)4 Map (java.util.Map)4 Modifications (com.thoughtworks.go.domain.materials.Modifications)3 Result (com.thoughtworks.go.plugin.api.response.Result)3 SimpleDateFormat (java.text.SimpleDateFormat)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)2 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)2 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)2 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)2