Search in sources :

Example 6 with SCMPropertyConfiguration

use of com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration 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 7 with SCMPropertyConfiguration

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

the class SCMsTest method shouldFailValidationIfMaterialWithDuplicateFingerprintIsFound.

@Test
void shouldFailValidationIfMaterialWithDuplicateFingerprintIsFound() {
    String pluginId = "plugin-id";
    SCMPropertyConfiguration scmConfiguration = new SCMPropertyConfiguration();
    scmConfiguration.add(new SCMProperty("k1"));
    scmConfiguration.add(new SCMProperty("k2").with(REQUIRED, false).with(PART_OF_IDENTITY, false));
    SCMMetadataStore.getInstance().addMetadataFor(pluginId, new SCMConfigurations(scmConfiguration), null);
    SCM scm1 = SCMMother.create("1", "scm1", pluginId, "1.0", new Configuration(create("k1", false, "v1")));
    SCM scm2 = SCMMother.create("2", "scm2", pluginId, "1.0", new Configuration(create("k1", false, "v2")));
    SCM scm3 = SCMMother.create("3", "scm3", pluginId, "1.0", new Configuration(create("k1", false, "v1")));
    SCM scm4 = SCMMother.create("4", "scm4", pluginId, "1.0", new Configuration(create("k1", false, "V1")));
    SCM scm5 = SCMMother.create("5", "scm5", pluginId, "1.0", new Configuration(create("k1", false, "v1"), create("k2", false, "v2")));
    SCMs scms = new SCMs(scm1, scm2, scm3, scm4, scm5);
    scms.validate(null);
    assertThat(scm2.getFingerprint().equals(scm1.getFingerprint())).isFalse();
    assertThat(scm3.getFingerprint().equals(scm1.getFingerprint())).isTrue();
    assertThat(scm4.getFingerprint().equals(scm1.getFingerprint())).isFalse();
    assertThat(scm5.getFingerprint().equals(scm1.getFingerprint())).isTrue();
    String expectedErrorMessage = "Cannot save SCM, found duplicate SCMs. scm1, scm3, scm5";
    assertThat(scm1.errors().getAllOn(SCM.SCM_ID)).isEqualTo(asList(expectedErrorMessage));
    assertThat(scm2.errors().getAllOn(SCM.SCM_ID)).isEmpty();
    assertThat(scm3.errors().getAllOn(SCM.SCM_ID)).isEqualTo(asList(expectedErrorMessage));
    assertThat(scm4.errors().getAllOn(SCM.SCM_ID)).isEmpty();
    assertThat(scm5.errors().getAllOn(SCM.SCM_ID)).isEqualTo(asList(expectedErrorMessage));
}
Also used : SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Configuration(com.thoughtworks.go.domain.config.Configuration) SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) SCMProperty(com.thoughtworks.go.plugin.access.scm.SCMProperty) Test(org.junit.jupiter.api.Test)

Aggregations

SCMPropertyConfiguration (com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration)7 MaterialPollResult (com.thoughtworks.go.plugin.access.scm.material.MaterialPollResult)3 SCMRevision (com.thoughtworks.go.plugin.access.scm.revision.SCMRevision)3 MaterialInstance (com.thoughtworks.go.domain.MaterialInstance)2 PluggableSCMMaterialRevision (com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision)2 SCMConfigurations (com.thoughtworks.go.plugin.access.scm.SCMConfigurations)2 SCMProperty (com.thoughtworks.go.plugin.access.scm.SCMProperty)2 Configuration (com.thoughtworks.go.domain.config.Configuration)1 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)1 Modifications (com.thoughtworks.go.domain.materials.Modifications)1 Result (com.thoughtworks.go.plugin.api.response.Result)1 Test (org.junit.jupiter.api.Test)1