private void addTimer(JsonObject pipeline, Map<String, Object> pipeMap) { Object timer = pipeMap.get(YAML_PIPELINE_TIMER_FIELD); if (timer == null) return; JsonObject timerJson = new JsonObject(); Map<String, Object> timerMap = (Map<String, Object>) timer; addRequiredString(timerJson, timerMap, "spec", "spec"); addOptionalBoolean(timerJson, timerMap, "only_on_changes", "only_on_changes"); pipeline.add(JSON_PIPELINE_TIMER_FIELD, timerJson); }
public JsonObject transform(Map.Entry<String, Object> entry) { String stageName = entry.getKey(); JsonObject stage = new JsonObject(); stage.addProperty(JSON_STAGE_NAME_FIELD, stageName); Map<String, Object> stageMap = (Map<String, Object>) entry.getValue(); addOptionalBoolean(stage, stageMap, JSON_STAGE_FETCH_FIELD, YAML_STAGE_FETCH_FIELD); addOptionalBoolean(stage, stageMap, JSON_STAGE_NEVER_CLEAN_FIELD, YAML_STAGE_KEEP_ARTIFACTS_FIELD); addOptionalBoolean(stage, stageMap, JSON_STAGE_CLEAN_WORK_FIELD, YAML_STAGE_CLEAN_WORK_FIELD); addApproval(stage, stageMap); JsonArray jsonEnvVariables = environmentTransform.transform(stageMap); if (jsonEnvVariables != null && jsonEnvVariables.size() > 0) stage.add(JSON_ENV_VAR_FIELD, jsonEnvVariables); addJobs(stage, stageMap); return stage; }
addOptionalBoolean(taskJson, taskMap, JSON_TASK_IS_FILE_FIELD, YAML_TASK_IS_FILE_FIELD); addOptionalStringList(taskJson, taskMap, JSON_TASK_EXEC_ARGS_FIELD, YAML_TASK_EXEC_ARGS_FIELD);
Map<String, Object> materialMap = (Map<String, Object>) entry.getValue(); addOptionalString(material, materialMap, JSON_MATERIAL_TYPE_FIELD, YAML_MATERIAL_TYPE_FIELD); addOptionalBoolean(material, materialMap, JSON_MATERIAL_AUTO_UPDATE_FIELD, YAML_MATERIAL_AUTO_UPDATE_FIELD); addOptionalBoolean(material, materialMap, JSON_MATERIAL_SHALLOW_CLONE_FIELD, YAML_MATERIAL_SHALLOW_CLONE_FIELD); addOptionalBoolean(material, materialMap, JSON_MATERIAL_CHECK_EXTERNALS_FIELD, YAML_MATERIAL_CHECK_EXTERNALS_FIELD); addOptionalBoolean(material, materialMap, JSON_MATERIAL_USE_TICKETS_FIELD, YAML_MATERIAL_USE_TICKETS_FIELD); if (materialMap.containsKey("blacklist")) addFilter(material, materialMap.get("blacklist"), "ignore");
public JsonObject transform(Map.Entry<String, Object> entry) { String pipelineName = entry.getKey(); JsonObject pipeline = new JsonObject(); pipeline.addProperty(JSON_PIPELINE_NAME_FIELD, pipelineName); Map<String, Object> pipeMap = (Map<String, Object>) entry.getValue(); addOptionalString(pipeline, pipeMap, JSON_PIPELINE_GROUP_FIELD, YAML_PIPELINE_GROUP_FIELD); addOptionalString(pipeline, pipeMap, JSON_PIPELINE_TEMPLATE_FIELD, YAML_PIPELINE_TEMPLATE_FIELD); addOptionalString(pipeline, pipeMap, JSON_PIPELINE_LABEL_TEMPLATE_FIELD, YAML_PIPELINE_LABEL_TEMPLATE_FIELD); addOptionalBoolean(pipeline, pipeMap, JSON_PIPELINE_PIPE_LOCKING_FIELD, YAML_PIPELINE_PIPE_LOCKING_FIELD); addOptionalString(pipeline, pipeMap, JSON_PIPELINE_LOCK_BEHAVIOR_FIELD, YAML_PIPELINE_LOCK_BEHAVIOR_FIELD); addOptionalObject(pipeline, pipeMap, JSON_PIPELINE_TRACKING_TOOL_FIELD, YAML_PIPELINE_TRACKING_TOOL_FIELD); addOptionalObject(pipeline, pipeMap, JSON_PIPELINE_MINGLE_FIELD, YAML_PIPELINE_MINGLE_FIELD); addTimer(pipeline, pipeMap); JsonArray jsonEnvVariables = variablesTransform.transform(pipeMap); if (jsonEnvVariables != null && jsonEnvVariables.size() > 0) pipeline.add(JSON_ENV_VAR_FIELD, jsonEnvVariables); addMaterials(pipeline, pipeMap); if (!pipeline.has(JSON_PIPELINE_TEMPLATE_FIELD)) { addStages(pipeline, pipeMap); } JsonArray params = parameterTransform.transform(pipeMap); if (params != null && params.size() > 0) { pipeline.add(YAML_PIPELINE_PARAMETERS_FIELD, params); } return pipeline; }