public void cleanupAllUsagesOfRole(Role roleToDelete) { for (StageConfig stage : getStages()) { stage.cleanupAllUsagesOfRole(roleToDelete); } }
public static void toJSONArray(OutputListWriter stagesWriter, PipelineTemplateConfig pipelineTemplateConfig) { pipelineTemplateConfig.getStages().forEach(stage -> { stagesWriter.addChild(stageWriter -> toJSON(stageWriter, stage)); }); }
private List<PluggableTask> getPluggableTask(PipelineTemplateConfig templateConfig) { List<PluggableTask> pluggableTasks = new ArrayList<>(); for (StageConfig stage : templateConfig.getStages()) { for (JobConfig job : stage.getJobs()) { for (Task task : job.getTasks()) { if (task instanceof PluggableTask) { pluggableTasks.add((PluggableTask) task); } } } } return pluggableTasks; }
public void encryptSecureProperties(CruiseConfig preprocessedConfig, PipelineTemplateConfig pipelineTemplateConfig) { if (doesNotHavePublishAndFetchExternalConfig()) { return; } for (StageConfig stageConfig : getStages()) { stageConfig.encryptSecureProperties(preprocessedConfig, pipelineTemplateConfig); } }
private void cachePublishAndFetchExternalConfig() { externalArtifactConfigs = new ArrayList<>(); fetchExternalArtifactTasks = new ArrayList<>(); for (StageConfig stageConfig : getStages()) { for (JobConfig jobConfig : stageConfig.getJobs()) { externalArtifactConfigs.addAll(jobConfig.artifactConfigs().getPluggableArtifactConfigs()); for (Task task : jobConfig.getTasks()) { if (task instanceof FetchPluggableArtifactTask) { fetchExternalArtifactTasks.add((FetchPluggableArtifactTask) task); } } } } }
private static void writeStages(OutputWriter jsonWriter, PipelineTemplateConfig pipelineTemplateConfig) { if (pipelineTemplateConfig.getStages().isEmpty()) { jsonWriter.renderNull("stages"); } else { jsonWriter.addChildList("stages", stagesWriter -> StageRepresenter.toJSONArray(stagesWriter, pipelineTemplateConfig)); } }
private static void setStages(JsonReader jsonReader, PipelineTemplateConfig pipelineTemplateConfig) { pipelineTemplateConfig.getStages().clear(); jsonReader.readArrayIfPresent("stages", stages -> { stages.forEach(stage -> { pipelineTemplateConfig.addStageWithoutValidityAssertion(StageRepresenter.fromJSON(new JsonReader(stage.getAsJsonObject()))); }); }); } }
@Test public void shouldAllowEditingOfStageNameWhenItIsNotUsedAsDependencyMaterial() throws Exception { PipelineTemplateConfig template = new PipelineTemplateConfig(new CaseInsensitiveString("template"), StageConfigMother.oneBuildPlanWithResourcesAndMaterials("stage2")); BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig(); cruiseConfig.addTemplate(template); template.getStages().get(0).setName(new CaseInsensitiveString("updatedStageName")); template.validateTree(ConfigSaveValidationContext.forChain(cruiseConfig), cruiseConfig, false); assertThat(template.errors().isEmpty(), is(true)); }
@Test public void shouldAllowEditingOfJobNameWhenItIsNotUsedAsFetchArtifact() throws Exception { PipelineTemplateConfig template = new PipelineTemplateConfig(new CaseInsensitiveString("template"), StageConfigMother.oneBuildPlanWithResourcesAndMaterials("stage", "job2")); BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig(); cruiseConfig.addTemplate(template); template.getStages().get(0).getJobs().get(0).setName(new CaseInsensitiveString("updatedJobName")); template.validateTree(ConfigSaveValidationContext.forChain(cruiseConfig), cruiseConfig, false); assertThat(template.errors().isEmpty(), is(true)); }