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));
}
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"));
}
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"));
}
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();
}
}
}
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);
}
Aggregations