public Stage createStageInstance(StageConfig stageConfig, SchedulingContext context, String md5, Clock clock) { return new Stage(CaseInsensitiveString.str(stageConfig.name()), createJobInstances(stageConfig, context, clock), context.getApprovedBy(), null, stageConfig.approvalType(), stageConfig.isFetchMaterials(), stageConfig.isCleanWorkingDir(), md5, clock); }
@Test public void shouldSetPrimitiveAttributes() throws Exception{ StageConfig config = new StageConfig(); config.setConfigAttributes(Collections.singletonMap(StageConfig.NAME, "foo_bar")); config.setConfigAttributes(Collections.singletonMap(StageConfig.FETCH_MATERIALS, "0")); config.setConfigAttributes(Collections.singletonMap(StageConfig.CLEAN_WORKING_DIR, "1")); assertThat(config.name(), is(new CaseInsensitiveString("foo_bar"))); assertThat(config.isFetchMaterials(), is(false)); assertThat(config.isCleanWorkingDir(), is(true)); }
public static void toJSON(OutputWriter jsonWriter, StageConfig stageConfig) { if (!stageConfig.errors().isEmpty()) { jsonWriter.addChild("errors", errorWriter -> { new ErrorGetter(new HashMap<>()).toJSON(errorWriter, stageConfig); }); } jsonWriter.addIfNotNull("name", stageConfig.name()); jsonWriter.add("fetch_materials", stageConfig.isFetchMaterials()); jsonWriter.add("clean_working_directory", stageConfig.isCleanWorkingDir()); jsonWriter.add("never_cleanup_artifacts", stageConfig.isArtifactCleanupProhibited()); jsonWriter.addChild("approval", approvalWriter -> ApprovalRepresenter.toJSON(approvalWriter, stageConfig.getApproval())); jsonWriter.addChildList("environment_variables", envVarsWriter -> EnvironmentVariableRepresenter.toJSON(envVarsWriter, stageConfig.getVariables())); jsonWriter.addChildList("jobs", getJobs(stageConfig)); }
public static void toJSON(OutputWriter jsonWriter, StageConfig stageConfig) { if (!stageConfig.errors().isEmpty()) { jsonWriter.addChild("errors", errorWriter -> { new ErrorGetter(new HashMap<>()).toJSON(errorWriter, stageConfig); }); } jsonWriter.addIfNotNull("name", stageConfig.name()); jsonWriter.add("fetch_materials", stageConfig.isFetchMaterials()); jsonWriter.add("clean_working_directory", stageConfig.isCleanWorkingDir()); jsonWriter.add("never_cleanup_artifacts", stageConfig.isArtifactCleanupProhibited()); jsonWriter.addChild("approval", approvalWriter -> ApprovalRepresenter.toJSON(approvalWriter, stageConfig.getApproval())); jsonWriter.addChildList("environment_variables", envVarsWriter -> EnvironmentVariableRepresenter.toJSON(envVarsWriter, stageConfig.getVariables())); jsonWriter.addChildList("jobs", getJobs(stageConfig)); }
CRStage stageToCRStage(StageConfig stageConfig) { CRStage crStage = new CRStage(stageConfig.name().toString()); for(JobConfig job: stageConfig.getJobs()) { crStage.addJob(jobToCRJob(job)); } for (EnvironmentVariableConfig var: stageConfig.getVariables()) { crStage.addEnvironmentVariable(environmentVariableConfigToCREnvironmentVariable(var)); } crStage.setApproval(approvalToCRApproval(stageConfig.getApproval())); crStage.setFetchMaterials(stageConfig.isFetchMaterials()); crStage.setArtifactCleanupProhibited(stageConfig.isArtifactCleanupProhibited()); crStage.setCleanWorkingDir(stageConfig.isCleanWorkingDir()); return crStage; }