use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class PipelineConfigDependencyGraph method unsharedMaterialConfigs.
public MaterialConfigs unsharedMaterialConfigs() {
MaterialConfigs firstOrderMaterials = new MaterialConfigs();
List<PipelineConfigQueueEntry> queue = new ArrayList<>(buildQueue());
for (MaterialConfig materialConfig : current.materialConfigs()) {
if (!existsOnAnyOfPipelinesIn(queue, materialConfig)) {
firstOrderMaterials.add(materialConfig);
}
}
return firstOrderMaterials;
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class PipelineConfigDependencyGraph method isRevisionsOfSharedMaterialsIgnored.
public boolean isRevisionsOfSharedMaterialsIgnored(MaterialRevisions revisions) {
MaterialConfigs unsharedScmMaterialConfigs = unsharedMaterialConfigs();
List<PipelineConfigQueueEntry> queue = new ArrayList<>(buildQueue());
for (MaterialRevision revision : revisions) {
Material material = revision.getMaterial();
MaterialConfig materialConfig = material.config();
if (unsharedScmMaterialConfigs.hasMaterialWithFingerprint(materialConfig) || revision.isDependencyMaterialRevision()) {
continue;
}
if (isThisMaterialIgnored(queue, revision, materialConfig)) {
return true;
}
}
return false;
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class BuildCauseProducerServiceConfigRepoIntegrationTest method shouldSchedulePipelineWithSameMaterialIn2DestinationsWhenManuallyTriggered_WithSpecifiedRevisions.
@Test
public void shouldSchedulePipelineWithSameMaterialIn2DestinationsWhenManuallyTriggered_WithSpecifiedRevisions() throws Exception {
pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages("pipe1", "build", "test");
pipelineConfig.materialConfigs().clear();
materialConfig = hgRepo.createMaterialConfig("dest1");
materialConfig.setAutoUpdate(true);
// new material is added
MaterialConfig otherMaterialConfig = hgRepo.createMaterialConfig("dest2");
otherMaterialConfig.setAutoUpdate(true);
pipelineConfig.materialConfigs().add(materialConfig);
pipelineConfig.materialConfigs().add(otherMaterialConfig);
List<Modification> firstBuildModifications = configTestRepo.addPipelineToRepositoryAndPush(fileName, pipelineConfig);
materialUpdateService.updateMaterial(material);
waitForMaterialNotInProgress();
cachedGoConfig.throwExceptionIfExists();
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<CaseInsensitiveString, BuildCause> afterLoad = scheduleHelper.waitForAnyScheduled(5);
assertThat(afterLoad.keySet(), hasItem(new CaseInsensitiveString(PIPELINE_NAME)));
BuildCause cause = afterLoad.get(new CaseInsensitiveString(PIPELINE_NAME));
assertThat(cause.getBuildCauseMessage(), containsString("Forced by anonymous"));
List<Modification> secondBuildModifications = configTestRepo.addCodeToRepositoryAndPush("a.java", "added code file", "some java code");
materialUpdateService.updateMaterial(material);
waitForMaterialNotInProgress();
pipelineScheduleQueue.clear();
// revision in dest 1 will be older by 1 commit - this is kind of scm-config-consistency violation
String explicitRevision = firstBuildModifications.get(0).getRevision();
revisions.put(materialConfig.getPipelineUniqueFingerprint(), explicitRevision);
buildCauseProducer.manualProduceBuildCauseAndSave(PIPELINE_NAME, new Username(new CaseInsensitiveString("Admin")), new ScheduleOptions(revisions, environmentVariables, new HashMap<>()), new ServerHealthStateOperationResult());
cachedGoConfig.throwExceptionIfExists();
afterLoad = scheduleHelper.waitForAnyScheduled(5);
assertThat(afterLoad.keySet(), hasItem(new CaseInsensitiveString(PIPELINE_NAME)));
cause = afterLoad.get(new CaseInsensitiveString(PIPELINE_NAME));
assertThat(cause.getBuildCauseMessage(), containsString("Forced by Admin"));
PipelineConfig pipelineConfigAfterSchedule = goConfigService.pipelineConfigNamed(pipelineConfig.name());
RepoConfigOrigin configOriginAfterSchedule = (RepoConfigOrigin) pipelineConfigAfterSchedule.getOrigin();
String lastPushedRevision = secondBuildModifications.get(0).getRevision();
assertThat("revisionOfPipelineConfigOriginShouldMatchLastPushedCommit", configOriginAfterSchedule.getRevision(), is(lastPushedRevision));
assertThat(pipelineConfigAfterSchedule.materialConfigs(), hasItem(otherMaterialConfig));
assertThat("buildCauseRevisionShouldMatchSpecifiedRevision", cause.getMaterialRevisions().latestRevision(), is(explicitRevision));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class ConfigRepoServiceIntegrationTest method setUp.
@BeforeEach
public void setUp() throws Exception {
user = new Username(new CaseInsensitiveString("current"));
UpdateConfigCommand command = goConfigService.modifyAdminPrivilegesCommand(asList(user.getUsername().toString()), new TriStateSelection(Admin.GO_SYSTEM_ADMIN, TriStateSelection.Action.add));
goConfigService.updateConfig(command);
this.repoId = "repo-1";
this.pluginId = "json-config-repo-plugin";
MaterialConfig repoMaterial = git("https://foo.git", "master");
this.configRepo = ConfigRepoConfig.createConfigRepoConfig(repoMaterial, pluginId, repoId);
configHelper.usingCruiseConfigDao(goConfigDao);
configHelper.onSetUp();
goConfigService.forceNotifyListeners();
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class BuildCause method assertPipelineConfigAndMaterialRevisionMatch.
public void assertPipelineConfigAndMaterialRevisionMatch(PipelineConfig pipelineConfig) {
if (!pipelineConfig.isConfigOriginSameAsOneOfMaterials()) {
return;
}
// then config and code revision must both match
if (this.trigger.isForced() || this.hasDependencyMaterials()) {
// and possibility to specify revisions to run with
return;
}
RepoConfigOrigin repoConfigOrigin = (RepoConfigOrigin) pipelineConfig.getOrigin();
MaterialConfig configAndCodeMaterial = repoConfigOrigin.getMaterial();
// TODO if revision in any of the pipelines match
MaterialRevision revision = this.getMaterialRevisions().findRevisionForFingerPrint(configAndCodeMaterial.getFingerprint());
String revisionString = revision.getRevision().getRevision();
if (pipelineConfig.isConfigOriginFromRevision(revisionString)) {
return;
}
invalidRevision(repoConfigOrigin.getRevision(), revisionString);
}
Aggregations