public PipelineConfig addStageToPipeline(String pipelineName, StageConfig stageConfig) { CruiseConfig cruiseConfig = loadForEdit(); PipelineConfig pipelineConfig = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName)); pipelineConfig.add(stageConfig); writeConfigFile(cruiseConfig); return pipelineConfig; }
@Test public void uniqueMaterialForAutoPipelinesShouldNotReturnPackageMaterialsWithAutoUpdateFalse() throws Exception { PipelineConfig pipeline1 = pipelineWithManyMaterials(false); pipeline1.add( new StageConfig( new CaseInsensitiveString("manual-stage"), new JobConfigs(), new Approval())); CruiseConfig config = new CruiseConfig(new PipelineConfigs(pipeline1)); assertThat(config.getAllUniqueMaterialsBelongingToAutoPipelines().size(), is(3)); }
@Test public void shouldIncludeScmMaterialsFromManualPipelinesInSchedulableMaterials() { PipelineConfig pipeline1 = pipelineWithManyMaterials(true); pipeline1.add( new StageConfig( new CaseInsensitiveString("manual-stage"), new JobConfigs(), new Approval())); CruiseConfig config = new CruiseConfig(new PipelineConfigs(pipeline1)); assertThat(config.getAllUniqueMaterialsBelongingToAutoPipelines().size(), is(4)); }
@Test public void shouldNotIncludePackageMaterialsWithAutoUpdateFalse() { PipelineConfig pipeline1 = pipelineWithManyMaterials(false); pipeline1.addMaterialConfig(getPackageMaterialConfigWithAutoUpdateFalse()); pipeline1.addMaterialConfig(getPackageMaterialConfigWithAutoUpdateTrue()); pipeline1.add( new StageConfig( new CaseInsensitiveString("manual-stage"), new JobConfigs(), new Approval())); CruiseConfig config = new CruiseConfig(new PipelineConfigs(pipeline1)); assertThat(config.getAllUniqueMaterialsBelongingToAutoPipelines().size(), is(4)); }
@Test public void shouldIncludeDependencyMaterialsFromManualPipelinesInSchedulableMaterials() { DependencyMaterialConfig dependencyMaterialConfig = MaterialConfigsMother.dependencyMaterialConfig(); PipelineConfig pipeline1 = new PipelineConfig( new CaseInsensitiveString("pipeline1"), new MaterialConfigs(dependencyMaterialConfig)); pipeline1.add( new StageConfig( new CaseInsensitiveString("manual-stage"), new JobConfigs(), new Approval())); CruiseConfig config = new CruiseConfig(new PipelineConfigs(pipeline1)); Set<MaterialConfig> materialConfigs = config.getAllUniqueMaterialsBelongingToAutoPipelines(); assertThat(materialConfigs.size(), is(1)); assertThat(materialConfigs.contains(dependencyMaterialConfig), is(true)); }