use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class ConfigRepositoryInitializer method initializeConfigRepository.
private void initializeConfigRepository(ConfigRepoConfig repo) {
MaterialConfig materialConfig = repo.getRepo();
Material material = new Materials(new MaterialConfigs(materialConfig)).first();
MaterialInstance materialInstance = this.materialRepository.findMaterialInstance(materialConfig);
if (materialInstance != null) {
File folder = materialRepository.folderFor(material);
MaterialRevisions latestModification = materialRepository.findLatestModification(material);
Modification modification = latestModification.firstModifiedMaterialRevision().getLatestModification();
try {
LOGGER.debug("[Config Repository Initializer] Initializing config repository '{}'. Loading the GoCD configuration from last fetched modification '{}'.", repo.getId(), modification.getRevision());
goConfigRepoConfigDataSource.onCheckoutComplete(materialConfig, folder, modification);
} catch (Exception e) {
LOGGER.error(String.format("[Config Repository Initializer] an error occurred while initializing '%s' config repository.", repo.getId()), e);
// Do nothing when error occurs while initializing the config repository.
// The config repo initialization may fail due to config repo errors (config errors, or rules violation errors)
}
} else {
LOGGER.debug("[Config Repository Initializer] Skipped initializing config repository '{}'. Could not find material repository under flyweight folder.", repo.getId());
}
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class PipelineRepositoryIntegrationTest method shouldConsider_firstRevision_forAFlyweight_asInDb_whilePickingFromMultipleDeclarations.
@Test
public void shouldConsider_firstRevision_forAFlyweight_asInDb_whilePickingFromMultipleDeclarations() {
ScheduleTestUtil u = new ScheduleTestUtil(transactionTemplate, materialRepository, dbHelper, configHelper);
int i = 1;
GitMaterial git1 = u.wf(new GitMaterial("git"), "folder1");
u.checkinInOrder(git1, "g1");
GitMaterial git2 = u.wf(new GitMaterial("git"), "folder2");
ScheduleTestUtil.AddedPipeline p = u.saveConfigWith("P", u.m(git1), u.m(git2));
CruiseConfig cruiseConfig = goConfigDao.load();
u.checkinInOrder(git1, u.d(i++), "g2");
u.runAndPass(p, "g1", "g2");
u.runAndPass(p, "g2", "g1");
PipelineTimeline timeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
timeline.updateTimelineOnInit();
List<PipelineTimelineEntry> timelineEntries = new ArrayList<>(timeline.getEntriesFor("P"));
assertThat(timelineEntries.get(0).getPipelineLocator().getCounter(), is(1));
assertThat(timelineEntries.get(0).naturalOrder(), is(1.0));
List<PipelineTimelineEntry.Revision> flyweightsRevs = new ArrayList<>(timelineEntries.get(0).revisions().values()).get(0);
assertThat(flyweightsRevs.get(0).revision, is("g1"));
assertThat(flyweightsRevs.get(1).revision, is("g2"));
assertThat(timelineEntries.get(1).getPipelineLocator().getCounter(), is(2));
assertThat(timelineEntries.get(1).naturalOrder(), is(2.0));
flyweightsRevs = new ArrayList<>(timelineEntries.get(1).revisions().values()).get(0);
assertThat(flyweightsRevs.get(0).revision, is("g2"));
assertThat(flyweightsRevs.get(1).revision, is("g1"));
MaterialConfigs materials = configHelper.deepClone(p.config.materialConfigs());
Collections.reverse(materials);
configHelper.setMaterialConfigForPipeline("P", materials.toArray(new MaterialConfig[0]));
goConfigDao.load();
timeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
timeline.updateTimelineOnInit();
timelineEntries = new ArrayList<>(timeline.getEntriesFor("P"));
assertThat(timelineEntries.get(0).getPipelineLocator().getCounter(), is(1));
assertThat(timelineEntries.get(0).naturalOrder(), is(1.0));
flyweightsRevs = new ArrayList<>(timelineEntries.get(0).revisions().values()).get(0);
assertThat(flyweightsRevs.get(0).revision, is("g1"));
assertThat(flyweightsRevs.get(1).revision, is("g2"));
assertThat(timelineEntries.get(1).getPipelineLocator().getCounter(), is(2));
assertThat(timelineEntries.get(1).naturalOrder(), is(2.0));
flyweightsRevs = new ArrayList<>(timelineEntries.get(1).revisions().values()).get(0);
assertThat(flyweightsRevs.get(0).revision, is("g2"));
assertThat(flyweightsRevs.get(1).revision, is("g1"));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class PipelineScheduleQueueIntegrationTest method shouldReturnNullWhenPipelineConfigOriginDoesNotMatchBuildCauseRevision.
@Test
public void shouldReturnNullWhenPipelineConfigOriginDoesNotMatchBuildCauseRevision() {
PipelineConfig pipelineConfig = fixture.pipelineConfig();
BuildCause cause = modifySomeFilesAndTriggerAs(pipelineConfig, "cruise-developer");
MaterialConfig materialConfig = pipelineConfig.materialConfigs().first();
cause.getMaterialRevisions().findRevisionFor(materialConfig);
pipelineConfig.setOrigins(new RepoConfigOrigin(ConfigRepoConfig.createConfigRepoConfig(materialConfig, "123", "id1"), "plug"));
saveRev(cause);
queue.schedule(new CaseInsensitiveString(fixture.pipelineName), cause);
Pipeline pipeline = queue.createPipeline(cause, pipelineConfig, new DefaultSchedulingContext(cause.getApprover(), new Agents()), "md5-test", new TimeProvider());
assertThat(pipeline, is(nullValue()));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class CruiseConfigTestBase method getAllUniquePostCommitSchedulableMaterials_shouldReturnMaterialsWithAutoUpdateFalseAndConfigRepos.
@Test
public void getAllUniquePostCommitSchedulableMaterials_shouldReturnMaterialsWithAutoUpdateFalseAndConfigRepos() {
GitMaterialConfig gitAutoMaterial = MaterialConfigsMother.gitMaterialConfig("url");
PipelineConfig pipelineAuto = pipelineConfig("pipelineAuto", new MaterialConfigs(gitAutoMaterial));
GitMaterialConfig gitNonAutoMaterial = new GitMaterialConfig(new UrlArgument("other-url"), "master", "dest", false, null, false, null, new CaseInsensitiveString("git"), false);
PipelineConfig pipelineTriggerable = pipelineConfig("pipelineTriggerable", new MaterialConfigs(gitNonAutoMaterial));
PipelineConfigs defaultGroup = createGroup("defaultGroup", pipelineAuto, pipelineTriggerable);
cruiseConfig = new BasicCruiseConfig(defaultGroup);
ConfigReposConfig reposConfig = new ConfigReposConfig();
GitMaterialConfig configRepoMaterial = new GitMaterialConfig("http://git");
reposConfig.add(new ConfigRepoConfig(configRepoMaterial, "myplug"));
cruiseConfig.setConfigRepos(reposConfig);
PipelineGroups pipelineGroups = new PipelineGroups(defaultGroup);
Set<MaterialConfig> materials = cruiseConfig.getAllUniquePostCommitSchedulableMaterials();
assertThat(materials.size(), is(2));
assertThat(materials, hasItem(gitNonAutoMaterial));
assertThat(materials, hasItem(configRepoMaterial));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class MaterialConfigsTest method shouldReturnMaterialBasedOnPiplineUniqueFingerPrint.
@Test
public void shouldReturnMaterialBasedOnPiplineUniqueFingerPrint() {
CruiseConfig cruiseConfig = new BasicCruiseConfig();
PipelineConfig pipeline1 = goConfigMother.addPipeline(cruiseConfig, "pipeline1", "stage", "build");
HgMaterialConfig expectedMaterial = MaterialConfigsMother.hgMaterialConfig();
pipeline1.addMaterialConfig(expectedMaterial);
pipeline1.addMaterialConfig(MaterialConfigsMother.gitMaterialConfig("url"));
pipeline1.addMaterialConfig(MaterialConfigsMother.svnMaterialConfig("url", "folder"));
MaterialConfig actualMaterialConfig = pipeline1.materialConfigs().getByFingerPrint(expectedMaterial.getPipelineUniqueFingerprint());
assertThat(actualMaterialConfig, is(expectedMaterial));
}
Aggregations