/** * Gets the run canary stages that contain the results */ @NotNull protected List<Stage> getRunCanaryStages(@Nonnull Stage stage) { // Collect the Run Canary Stages where the parent id is itself // Sorting by number after the # in the name return stage.getExecution().getStages().stream() .filter(s -> s.getType().equals(RunCanaryStage.STAGE_TYPE)) .sorted(Comparator.comparing(s -> Integer.valueOf(StringUtils.substringAfterLast(s.getName(), "#")))) .collect(Collectors.toList()); }
.stream() .collect( Collectors.toMap(s -> s.getName(), s -> s.getContext().get("exception")) ));
.stageStatus(pipeline.getStages() .stream() .map(stage -> new StageMetadata(stage.getType(), stage.getName(), stage.getStatus())) .collect(Collectors.toList())) .complete(isComplete)
/** * Gets the run canary stages that contain the results */ @NotNull protected List<Stage> getRunCanaryStages(@Nonnull Stage stage) { // Collect the Run Canary Stages where the parent id is itself // Sorting by number after the # in the name return stage.getExecution().getStages().stream() .filter(s -> s.getType().equals(RunCanaryStage.STAGE_TYPE)) .sorted(Comparator.comparing(s -> Integer.valueOf(StringUtils.substringAfterLast(s.getName(), "#")))) .collect(Collectors.toList()); }
/** * Checks existence of a Stage by id * @param obj #root.execution * @param id the name or id of the stage to check existence * @return W */ static boolean stageExists(Object obj, String id) { if (obj instanceof Execution) { Execution execution = (Execution) obj; return execution.getStages() .stream() .anyMatch(i -> id != null && (id.equals(i.getName()) || id.equals(i.getId()))); } throw new SpelHelperFunctionException(String.format("Invalid first param to #stage(%s). must be an execution", id)); }
private static Predicate<Stage> isManualStageWithManualInput(String id) { return i -> (id != null && id.equals(i.getName())) && (i.getContext() != null && i.getType().equals("manualJudgment") && i.getContext().get("judgmentInput") != null); }
private static Predicate<Stage> matchesDeployedStage(String ...id) { List<String> idsOrNames = Arrays.asList(id); if (!idsOrNames.isEmpty()){ return stage -> DEPLOY_STAGE_NAMES.contains(stage.getType()) && stage.getContext().containsKey("deploy.server.groups") && stage.getStatus() == ExecutionStatus.SUCCEEDED && (idsOrNames.contains(stage.getName()) || idsOrNames.contains(stage.getId())); } else { return stage -> DEPLOY_STAGE_NAMES.contains(stage.getType()) && stage.getContext().containsKey("deploy.server.groups") && stage.getStatus() == ExecutionStatus.SUCCEEDED; } } }
/** * Finds a Stage by id * @param obj #root.execution * @param id the name or id of the stage to find * @return a stage specified by id */ static Object stage(Object obj, String id) { if (obj instanceof Execution) { Execution execution = (Execution) obj; return execution.getStages() .stream() .filter(i -> id != null && (id.equals(i.getName()) || id.equals(i.getId()))) .findFirst() .orElseThrow( () -> new SpelHelperFunctionException( String.format("Unable to locate [%s] using #stage(%s) in execution %s", id, id, execution.getId()) ) ); } throw new SpelHelperFunctionException(String.format("Invalid first param to #stage(%s). must be an execution", id)); }
.stream() .collect( Collectors.toMap(s -> s.getName(), s -> s.getContext().get("exception")) ));
public StageStarted( @Nonnull Object source, @Nonnull Stage stage ) { this(source, stage.getExecution().getType(), stage.getExecution().getId(), stage.getId(), stage.getType(), stage.getName()); }
private TaskResult handleRetrofitError(Stage stage, RetrofitError e) { if (e.getResponse() == null) { throw e; } switch (e.getResponse().getStatus()) { case 404: return new TaskResult(ExecutionStatus.SUCCEEDED); case 500: Map<String, Object> error = new HashMap<>(); error.put("lastRetrofitException", new RetrofitExceptionHandler().handle(stage.getName(), e)); LOGGER.error("Unexpected retrofit error {}", error.get("lastRetrofitException"), e); return new TaskResult(ExecutionStatus.RUNNING, error); default: throw e; } }
public StageComplete( @Nonnull Object source, @Nonnull Stage stage ) { this(source, stage.getExecution().getType(), stage.getExecution().getId(), stage.getId(), stage.getType(), stage.getName(), stage.getStatus()); }
map.put(prefix + "refId", stage.getRefId()); map.put(prefix + "type", stage.getType()); map.put(prefix + "name", stage.getName()); map.put(prefix + "startTime", stage.getStartTime() != null ? stage.getStartTime().toString() : null); map.put(prefix + "endTime", stage.getEndTime() != null ? stage.getEndTime().toString() : null);
deleteResult.add(imageId); } else { outputs.put("lastRetrofitException", new RetrofitExceptionHandler().handle(stage.getName(), e)); log.error("Unexpected retrofit error {}", outputs.get("lastRetrofitException"), e);
public TaskStarted( @Nonnull Object source, @Nonnull Stage stage, @Nonnull Task task ) { this( source, stage.getExecution().getType(), stage.getExecution().getId(), stage.getId(), stage.getType(), stage.getName(), task.getId(), task.getImplementingClass(), task.getName() ); }
public TaskComplete( @Nonnull Object source, @Nonnull Stage stage, @Nonnull Task task ) { this( source, stage.getExecution().getType(), stage.getExecution().getId(), stage.getId(), stage.getType(), stage.getName(), task.getId(), task.getImplementingClass(), task.getName(), task.getStatus() ); }
.stageStatus(pipeline.getStages() .stream() .map(stage -> new StageMetadata(stage.getType(), stage.getName(), stage.getStatus())) .collect(Collectors.toList())) .complete(isComplete)