use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.
the class MaterialConfigService method getMaterialConfigs.
public MaterialConfigs getMaterialConfigs(String username) {
MaterialConfigs materialConfigs = new MaterialConfigs();
Set<String> materialFingerprints = new HashSet<>();
for (PipelineConfigs pipelineGroup : goConfigService.groups()) {
if (securityService.hasViewPermissionForGroup(username, pipelineGroup.getGroup())) {
for (PipelineConfig pipelineConfig : pipelineGroup) {
for (MaterialConfig currentMaterialConfig : pipelineConfig.materialConfigs()) {
if (!materialFingerprints.contains(currentMaterialConfig.getFingerprint())) {
materialConfigs.add(currentMaterialConfig);
materialFingerprints.add(currentMaterialConfig.getFingerprint());
}
}
}
}
}
return materialConfigs;
}
use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.
the class MingleConfigService method mingleConfigForPipelineNamed.
public MingleConfig mingleConfigForPipelineNamed(String pipelineName, Username user, HttpLocalizedOperationResult result) {
if (!securityService.hasViewPermissionForPipeline(user, pipelineName)) {
result.unauthorized(LocalizedMessage.cannotViewPipeline(pipelineName), HealthStateType.unauthorisedForPipeline(pipelineName));
return null;
}
PipelineConfig pipelineConfig = goConfigService.pipelineConfigNamed(new CaseInsensitiveString(pipelineName));
MingleConfig mingleConfig = pipelineConfig.getMingleConfig();
return mingleConfig.equals(new MingleConfig()) ? null : mingleConfig;
}
use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.
the class PipelineService method populateRevisionsUsingUpstream.
private void populateRevisionsUsingUpstream(MaterialRevisions actualRevisions, MaterialRevisions newRevisions, DependencyMaterialRevision dmr, PipelineConfigDependencyGraph.PipelineConfigQueueEntry configQueueEntry) {
if (!configQueueEntry.containsPipelineInPath(dmr.getPipelineName())) {
return;
}
for (MaterialRevision materialRevision : actualRevisions) {
Material material = materialRevision.getMaterial();
if (currentPipelineHasMaterial(configQueueEntry, material) && !alreadyAdded(newRevisions, material)) {
List<PipelineConfig> paths = removePathHead(configQueueEntry);
if (!paths.isEmpty()) {
MaterialRevision revision = getRevisionFor(paths, dmr, material);
// revision is null when an upstream is both parent and grandparent
if (revision != null) {
materialRevision.replaceModifications(revision.getModifications());
newRevisions.addRevision(materialRevision);
}
}
}
}
}
use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.
the class BuildCauseProducerServiceIntegrationTest method shouldTriggerMDUOfConfigRepoMaterialIfThePipelineIsDefinedRemotelyInAConfigRepo_ManualTriggerOfPipeline_EvenIfMDUOptionIsTurnedOFFInRequest.
@Test
public void shouldTriggerMDUOfConfigRepoMaterialIfThePipelineIsDefinedRemotelyInAConfigRepo_ManualTriggerOfPipeline_EvenIfMDUOptionIsTurnedOFFInRequest() throws Exception {
ConfigRepoConfig repoConfig = new ConfigRepoConfig(new GitMaterialConfig("url2"), "plugin");
configHelper.addConfigRepo(repoConfig);
PartialConfig partialConfig = PartialConfigMother.withPipelineMultipleMaterials("remote_pipeline", new RepoConfigOrigin(repoConfig, "4567"));
PipelineConfig remotePipeline = partialConfig.getGroups().first().getPipelines().get(0);
GitMaterial git = u.wf((GitMaterial) new MaterialConfigConverter().toMaterial(remotePipeline.materialConfigs().getGitMaterial()), "git");
u.checkinInOrder(git, u.d(1), "g1r1");
SvnMaterial svn = u.wf((SvnMaterial) new MaterialConfigConverter().toMaterial(remotePipeline.materialConfigs().getSvnMaterial()), "svn");
u.checkinInOrder(svn, u.d(1), "svn1r11");
GitMaterial configRepoMaterial = u.wf((GitMaterial) new MaterialConfigConverter().toMaterial(repoConfig.getMaterialConfig()), "git");
u.checkinInOrder(configRepoMaterial, u.d(1), "s1");
goPartialConfig.onSuccessPartialConfig(repoConfig, partialConfig);
assertTrue(goConfigService.hasPipelineNamed(remotePipeline.name()));
scheduleOptions.shouldPerformMDUBeforeScheduling(false);
service.manualSchedulePipeline(username, remotePipeline.name(), scheduleOptions, result);
assertThat(result.isSuccess(), is(true));
assertThat(result.message(), is("Request to schedule pipeline remote_pipeline accepted"));
assertThat(materialUpdateStatusNotifier.hasListenerFor(remotePipeline), is(true));
assertMDUPendingForMaterial(remotePipeline, configRepoMaterial);
assertMDUNotPendingForMaterial(remotePipeline, svn);
assertMDUNotPendingForMaterial(remotePipeline, git);
assertThat(triggerMonitor.isAlreadyTriggered(remotePipeline.name().toString()), Is.is(true));
BuildCause buildCause = pipelineScheduleQueue.toBeScheduled().get(remotePipeline.name().toString());
assertNull(buildCause);
}
use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.
the class BuildCauseProducerServiceIntegrationTest method setup.
@Before
public void setup() throws Exception {
diskSpaceSimulator = new DiskSpaceSimulator();
new HgTestRepo("testHgRepo", temporaryFolder);
svnRepository = new SvnTestRepo(temporaryFolder);
dbHelper.onSetUp();
configHelper.onSetUp();
configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
repository = new SvnCommand(null, svnRepository.projectRepositoryUrl());
PipelineConfig goParentPipelineConfig = configHelper.addPipeline(GO_PIPELINE_UPSTREAM, STAGE_NAME, new MaterialConfigs(new GitMaterialConfig("foo-bar")), "unit");
goPipelineConfig = configHelper.addPipeline(GO_PIPELINE_NAME, STAGE_NAME, repository, "unit");
svnMaterialRevs = new MaterialRevisions();
svnMaterial = SvnMaterial.createSvnMaterialWithMock(repository);
svnMaterialRevs.addRevision(svnMaterial, svnMaterial.latestModification(null, new ServerSubprocessExecutionContext(goConfigService, new SystemEnvironment())));
final MaterialRevisions materialRevisions = new MaterialRevisions();
SvnMaterial anotherSvnMaterial = SvnMaterial.createSvnMaterialWithMock(repository);
materialRevisions.addRevision(anotherSvnMaterial, anotherSvnMaterial.latestModification(null, subprocessExecutionContext));
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
materialRepository.save(svnMaterialRevs);
}
});
BuildCause buildCause = BuildCause.createWithModifications(svnMaterialRevs, "");
mingleConfig = configHelper.addPipeline(MINGLE_PIPELINE_NAME, STAGE_NAME, repository, new Filter(new IgnoredFiles("**/*.doc")), "unit", "functional");
latestPipeline = PipelineMother.schedule(this.mingleConfig, buildCause);
latestPipeline = pipelineDao.saveWithStages(latestPipeline);
dbHelper.passStage(latestPipeline.getStages().first());
pipelineScheduleQueue.clear();
result = new HttpOperationResult();
scheduleOptions = new ScheduleOptions();
u = new ScheduleTestUtil(transactionTemplate, materialRepository, dbHelper, configHelper);
materialForManualTriggerPipeline = u.wf(new SvnMaterial("svn", "username", "password", false), "folder1");
u.checkinInOrder(materialForManualTriggerPipeline, u.d(1), "s1");
manualTriggerPipeline = configHelper.addPipeline(UUID.randomUUID().toString(), STAGE_NAME, materialForManualTriggerPipeline.config(), "build");
username = Username.ANONYMOUS;
}
Aggregations