use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class MaterialConfigServiceTest method shouldPopulateErrorCorrectlyWhenMaterialNotFound_getMaterialConfigByFingerprint.
@Test
public void shouldPopulateErrorCorrectlyWhenMaterialNotFound_getMaterialConfigByFingerprint() {
HttpOperationResult result = new HttpOperationResult();
MaterialConfig materialConfig = materialConfigService.getMaterialConfig(user, "unknown-fingerprint", result);
assertThat(materialConfig, is(nullValue()));
assertThat(result.httpCode(), is(404));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class PipelineGroups method getAllUniquePostCommitSchedulableMaterials.
public Set<MaterialConfig> getAllUniquePostCommitSchedulableMaterials() {
Set<MaterialConfig> materialConfigs = new HashSet<>();
Set<String> uniqueMaterials = new HashSet<>();
for (PipelineConfigs pipelineConfigs : this) {
for (PipelineConfig pipelineConfig : pipelineConfigs) {
for (MaterialConfig materialConfig : pipelineConfig.materialConfigs()) {
if ((materialConfig instanceof ScmMaterialConfig || materialConfig instanceof PluggableSCMMaterialConfig) && !materialConfig.isAutoUpdate() && !uniqueMaterials.contains(materialConfig.getFingerprint())) {
materialConfigs.add(materialConfig);
uniqueMaterials.add(materialConfig.getFingerprint());
}
}
}
}
return materialConfigs;
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class ReportingDependencyFanInNode method printCurrentAndOldSCMs.
private void printCurrentAndOldSCMs(ReportingFanInGraphContext context, Set<MaterialConfig> currentScmMaterials, List<ReportingFaninScmMaterial> scmMaterials, Pair<StageIdentifier, List<ReportingFaninScmMaterial>> stageIdentifierScmPair) {
context.out.println();
context.out.println("----");
context.out.println("SCM Materials in config:");
context.out.println(currentScmMaterials);
final Set<MaterialConfig> scmMaterialsInRev = new HashSet<>();
for (ReportingFaninScmMaterial scmMaterial : scmMaterials) {
final MaterialConfig scm = context.fingerprintScmMaterialMap.get(scmMaterial.fingerprint);
scmMaterialsInRev.add(scm);
}
context.out.println("----");
context.out.println("SCM Materials in Latest Revision:");
context.out.println(scmMaterialsInRev);
context.out.println("----");
context.out.println("Latest Revision of Material:");
context.out.println(stageIdentifierScmPair.first());
context.out.println("----");
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class ReportingFanInGraph method getPipelineScmDepMap.
public Map<DependencyMaterialConfig, Set<MaterialConfig>> getPipelineScmDepMap() {
Map<DependencyMaterialConfig, Set<MaterialConfig>> dependencyMaterialListMap = new HashMap<>();
for (Map.Entry<DependencyMaterialConfig, Set<String>> materialSetEntry : dependencyMaterialFingerprintMap.entrySet()) {
HashSet<MaterialConfig> scmMaterials = new HashSet<>();
for (String fingerprint : materialSetEntry.getValue()) {
scmMaterials.add(fingerprintScmMaterialMap.get(fingerprint));
}
dependencyMaterialListMap.put(materialSetEntry.getKey(), scmMaterials);
}
return dependencyMaterialListMap;
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class BuildCauseProducerServiceConfigRepoIntegrationTest method shouldReloadPipelineConfigurationAndUpdateNewMaterialWhenManuallyTriggered.
@Test
public void shouldReloadPipelineConfigurationAndUpdateNewMaterialWhenManuallyTriggered() throws Exception {
GitTestRepo otherGitRepo = new GitTestRepo(temporaryFolder);
pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages("pipe1", "build", "test");
pipelineConfig.materialConfigs().clear();
materialConfig = hgRepo.createMaterialConfig("dest1");
materialConfig.setAutoUpdate(true);
pipelineConfig.materialConfigs().add(materialConfig);
// new material is added
GitMaterial gitMaterial = otherGitRepo.createMaterial("dest2");
gitMaterial.setAutoUpdate(true);
MaterialConfig otherMaterialConfig = gitMaterial.config();
otherMaterialConfig.setAutoUpdate(true);
pipelineConfig.materialConfigs().add(otherMaterialConfig);
List<Modification> mod = configTestRepo.addPipelineToRepositoryAndPush(fileName, pipelineConfig);
final HashMap<String, String> revisions = new HashMap<>();
final HashMap<String, String> environmentVariables = new HashMap<>();
buildCauseProducer.manualProduceBuildCauseAndSave(PIPELINE_NAME, Username.ANONYMOUS, new ScheduleOptions(revisions, environmentVariables, new HashMap<>()), new ServerHealthStateOperationResult());
cachedGoConfig.throwExceptionIfExists();
Map<String, BuildCause> afterLoad = scheduleHelper.waitForAnyScheduled(20);
assertThat(afterLoad.keySet(), hasItem(PIPELINE_NAME));
BuildCause cause = afterLoad.get(PIPELINE_NAME);
assertThat(cause.getBuildCauseMessage(), containsString("Forced by anonymous"));
PipelineConfig pipelineConfigAfterSchedule = goConfigService.pipelineConfigNamed(pipelineConfig.name());
RepoConfigOrigin configOriginAfterSchedule = (RepoConfigOrigin) pipelineConfigAfterSchedule.getOrigin();
String lastPushedRevision = mod.get(0).getRevision();
assertThat("revisionOfPipelineConfigOriginShouldMatchLastPushedCommit", configOriginAfterSchedule.getRevision(), is(lastPushedRevision));
assertThat(pipelineConfig.materialConfigs(), hasItem(otherMaterialConfig));
assertThat("buildCauseRevisionShouldMatchLastPushedCommit", cause.getMaterialRevisions().latestRevision(), is(lastPushedRevision));
// update of commited material happened during manual trigger
MaterialRevisions modificationsInDb = materialRepository.findLatestModification(gitMaterial);
assertThat(modificationsInDb.latestRevision(), is(otherGitRepo.latestModification().get(0).getRevision()));
}
Aggregations