use of com.thoughtworks.go.config.materials.PluggableSCMMaterial 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
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.
the class MaterialInstanceTest method shouldAnswerRequiresUpdate.
@Test
public void shouldAnswerRequiresUpdate() {
PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial();
MaterialInstance materialInstance = material.createMaterialInstance();
// null
materialInstance.setAdditionalData(null);
assertThat(materialInstance.requiresUpdate(null), is(false));
assertThat(materialInstance.requiresUpdate(new HashMap<>()), is(false));
// empty
materialInstance.setAdditionalData(JsonHelper.toJsonString(new HashMap<String, String>()));
assertThat(materialInstance.requiresUpdate(null), is(false));
assertThat(materialInstance.requiresUpdate(new HashMap<>()), is(false));
// with data
Map<String, String> data = new HashMap<>();
data.put("k1", "v1");
data.put("k2", "v2");
materialInstance.setAdditionalData(JsonHelper.toJsonString(data));
assertThat(materialInstance.requiresUpdate(null), is(true));
assertThat(materialInstance.requiresUpdate(new HashMap<>()), is(true));
assertThat(materialInstance.requiresUpdate(data), is(false));
// missing key-value
Map<String, String> dataWithMissingKey = new HashMap<>(data);
dataWithMissingKey.remove("k1");
assertThat(materialInstance.requiresUpdate(dataWithMissingKey), is(true));
// extra key-value
Map<String, String> dataWithExtraKey = new HashMap<>(data);
dataWithExtraKey.put("k3", "v3");
assertThat(materialInstance.requiresUpdate(dataWithExtraKey), is(true));
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.
the class PluggableSCMPostCommitHookImplementer method prune.
@Override
public Set<Material> prune(Set<Material> materials, Map params) {
HashSet<Material> prunedCollection = new HashSet<>();
String paramSCMName = (String) params.get(SCM_NAME);
if (StringUtils.isNotBlank(paramSCMName)) {
for (Material material : materials) {
if (material instanceof PluggableSCMMaterial && paramSCMName.equalsIgnoreCase(((PluggableSCMMaterial) material).getScmConfig().getName())) {
prunedCollection.add(material);
}
}
}
return prunedCollection;
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.
the class JsonMessageHandler2_0_Test method createPipeline.
private Pipeline createPipeline() throws Exception {
Pipeline pipeline = PipelineMother.pipelineWithAllTypesOfMaterials("pipeline-name", "stage-name", "job-name", "1");
List<MaterialRevision> materialRevisions = pipeline.getMaterialRevisions().getRevisions();
PackageDefinition packageDefinition = ((PackageMaterial) materialRevisions.get(6).getMaterial()).getPackageDefinition();
packageDefinition.getRepository().getConfiguration().get(1).handleSecureValueConfiguration(true);
packageDefinition.getConfiguration().addNewConfigurationWithValue("k4", "package-v2", false);
packageDefinition.getConfiguration().get(1).handleSecureValueConfiguration(true);
SCM scm = ((PluggableSCMMaterial) materialRevisions.get(7).getMaterial()).getScmConfig();
scm.getConfiguration().get(1).handleSecureValueConfiguration(true);
Stage stage = pipeline.getFirstStage();
stage.setId(1L);
stage.setPipelineId(1L);
stage.setCreatedTime(new Timestamp(getFixedDate().getTime()));
stage.setLastTransitionedTime(new Timestamp(getFixedDate().getTime()));
JobInstance job = stage.getJobInstances().get(0);
job.setScheduledDate(getFixedDate());
job.getTransition(JobState.Assigned).setStateChangeTime(getFixedDate());
job.getTransition(JobState.Completed).setStateChangeTime(getFixedDate());
return pipeline;
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.
the class PluggableSCMMaterialInstance method toOldMaterial.
@Override
public Material toOldMaterial(String name, String folder, String password) {
PluggableSCMMaterial pluggableSCMMaterial = JsonHelper.fromJson(configuration, PluggableSCMMaterial.class);
pluggableSCMMaterial.setName(new CaseInsensitiveString(name));
pluggableSCMMaterial.setId(id);
pluggableSCMMaterial.setFolder(folder);
pluggableSCMMaterial.setFingerprint(getFingerprint());
return pluggableSCMMaterial;
}
Aggregations