Search in sources :

Example 21 with Modifications

use of com.thoughtworks.go.domain.materials.Modifications 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 22 with Modifications

use of com.thoughtworks.go.domain.materials.Modifications in project gocd by gocd.

the class PluggableSCMMaterialTest method shouldNotThrowUpWhenAdditionalDataIsRandomJunkAndNotJSON.

@Test
public void shouldNotThrowUpWhenAdditionalDataIsRandomJunkAndNotJSON() {
    ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "v1");
    SCM scmConfig = SCMMother.create("scm-id", "tw-dev", "pluginid", "version", new Configuration(k1));
    PluggableSCMMaterial material = new PluggableSCMMaterial();
    material.setSCMConfig(scmConfig);
    material.setName(new CaseInsensitiveString("tw-dev:go-agent"));
    Modifications modifications = new Modifications(new Modification("loser", "comment", "email", new Date(), "revision-123", "salkdfjdsa-jjgkj!!!vcxknbvkjk"));
    EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
    material.populateEnvironmentContext(environmentVariableContext, new MaterialRevision(material, modifications), null);
    assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_LABEL"), is("revision-123"));
    assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_K1"), is("v1"));
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) Modification(com.thoughtworks.go.domain.materials.Modification) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) SCM(com.thoughtworks.go.domain.scm.SCM) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) PluggableSCMMaterialRevision(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Test(org.junit.Test)

Example 23 with Modifications

use of com.thoughtworks.go.domain.materials.Modifications in project gocd by gocd.

the class PluggableSCMMaterialTest method shouldNotThrowUpWhenAdditionalDataIsNull.

@Test
public void shouldNotThrowUpWhenAdditionalDataIsNull() {
    ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "v1");
    SCM scmConfig = SCMMother.create("scm-id", "tw-dev", "pluginid", "version", new Configuration(k1));
    PluggableSCMMaterial material = new PluggableSCMMaterial();
    material.setSCMConfig(scmConfig);
    material.setName(new CaseInsensitiveString("tw-dev:go-agent"));
    Modifications modifications = new Modifications(new Modification("loser", "comment", "email", new Date(), "revision-123", null));
    EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
    material.populateEnvironmentContext(environmentVariableContext, new MaterialRevision(material, modifications), null);
    assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_LABEL"), is("revision-123"));
    assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_K1"), is("v1"));
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) Modification(com.thoughtworks.go.domain.materials.Modification) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) SCM(com.thoughtworks.go.domain.scm.SCM) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) PluggableSCMMaterialRevision(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Test(org.junit.Test)

Example 24 with Modifications

use of com.thoughtworks.go.domain.materials.Modifications 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 25 with Modifications

use of com.thoughtworks.go.domain.materials.Modifications in project gocd by gocd.

the class MaterialDatabaseUpdater method insertLatestOrNewModifications.

private void insertLatestOrNewModifications(Material material, MaterialInstance materialInstance, File folder, MaterialUpdater updater) {
    MaterialRevisions materialRevisions = materialRepository.findLatestModification(material);
    Modifications list = materialRevisions.getModifications(material);
    updater.insertLatestOrNewModifications(material, materialInstance, folder, list);
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions)

Aggregations

Modifications (com.thoughtworks.go.domain.materials.Modifications)35 Test (org.junit.Test)29 Modification (com.thoughtworks.go.domain.materials.Modification)21 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)15 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)12 Date (java.util.Date)12 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)10 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)10 MaterialInstance (com.thoughtworks.go.domain.MaterialInstance)9 File (java.io.File)8 HashMap (java.util.HashMap)6 LinkedHashMap (java.util.LinkedHashMap)6 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)5 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)5 PackageMaterialRevision (com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialRevision)5 PluggableSCMMaterialRevision (com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision)5 SCM (com.thoughtworks.go.domain.scm.SCM)5 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)4 TransactionStatus (org.springframework.transaction.TransactionStatus)4 TransactionCallback (org.springframework.transaction.support.TransactionCallback)4