/** * 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()); }
.stageStatus(pipeline.getStages() .stream() .map(stage -> new StageMetadata(stage.getType(), stage.getName(), stage.getStatus())) .collect(Collectors.toList())) .complete(isComplete) .filter(stage -> stage.getType().equals(SetupAndExecuteCanariesStage.STAGE_TYPE)) .findFirst() .ifPresent(stage -> Optional .filter(stage -> stage.getType().equals(GenerateCanaryAnalysisResultStage.STAGE_TYPE)) .findFirst() .ifPresent(generateCanaryAnalysisResultStage -> Optional
@Override public boolean supports(String cloudProvider, Stage stage) { if (!cloudProvider.equals(TITUS)) { return false; } return SUPPORTED_STAGES.contains(stage.getType().toLowerCase()); }
public boolean supports(String cloudProvider, Stage stage) { if (!cloudProvider.equals(KUBERNETES)) { return false; } return SUPPORTED_STAGES.contains(stage.getType().toLowerCase()); }
@Nullable public Stage namedStage(String type) { return stages .stream() .filter(it -> it.getType().equals(type)) .findFirst() .orElse(null); }
/** * 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()); }
/** * As per `Stage.ancestors` except this method returns tuples of the stages * and their `StageDefinitionBuilder`. */ public List<Result> ancestors(Stage startingStage) { return startingStage .ancestors() .stream() .map(it -> new Result(it, stageDefinitionBuilders.get(it.getType())) ) .collect(toList()); }
@Override public @Nonnull StageDefinitionBuilder builderFor( @Nonnull Stage stage) throws NoSuchStageDefinitionBuilder { return stageDefinitionBuilders .stream() .filter((it) -> it.getType().equals(stage.getType()) || it.getType().equals(stage.getContext().get("alias"))) .findFirst() .orElseThrow(() -> { List<String> knownTypes = stageDefinitionBuilders.stream().map(it -> it.getType()).sorted().collect(toList()); return new NoSuchStageDefinitionBuilder(stage.getType(), knownTypes); }); } }
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; } } }
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); }
.filter(it -> "deploy".equals(it.getType())) .forEach(deployStage -> { List<Map> clusters = (List<Map>) deployStage.getContext().getOrDefault("clusters", new ArrayList<>()); .filter(it -> "canary".equals(it.getType())) .forEach(canaryStage -> { List<Map> clusterPairs = (List<Map>)canaryStage.getContext().getOrDefault("clusterPairs", new ArrayList<>());
stage.getExecution().getStages() .stream() .filter(s -> lockTypes.contains(s.getType()) && s.getStatus() == ExecutionStatus.SUCCEEDED) .forEach(s -> { LockContext lc = s.mapTo("/lock", LockContext.LockContextBuilder.class).withStage(s).build(); new HeldLock(lc.getLockName(), lc.getLockValue()), hl -> new AtomicInteger(0)); if (AcquireLockStage.PIPELINE_TYPE.equals(s.getType())) { count.incrementAndGet(); } else {
public StageStarted( @Nonnull Object source, @Nonnull Stage stage ) { this(source, stage.getExecution().getType(), stage.getExecution().getId(), stage.getId(), stage.getType(), stage.getName()); }
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<String, String> map = new HashMap<>(); 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);
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() ); }
@Override public void onApplicationEvent(ExecutionComplete event) { if (!lockingConfigurationProperties.isEnabled()) { return; } if (event.getStatus().isHalt()) { try { MDC.put(AGENT_MDC_KEY, this.getClass().getSimpleName()); Execution execution = executionRepository.retrieve(event.getExecutionType(), event.getExecutionId()); execution.getStages().forEach(s -> { if (AcquireLockStage.PIPELINE_TYPE.equals(s.getType())) { try { LockContext lc = s.mapTo("/lock", LockContext.LockContextBuilder.class).withStage(s).build(); lockManager.releaseLock(lc.getLockName(), lc.getLockValue(), lc.getLockHolder()); } catch (LockFailureException lfe) { logger.info("Failure releasing lock in ExecutionCompleteLockReleasingListener - ignoring", lfe); } } }); } finally { MDC.remove(AGENT_MDC_KEY); } } } }
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) .filter(stage -> stage.getType().equals(SetupAndExecuteCanariesStage.STAGE_TYPE)) .findFirst() .ifPresent(stage -> Optional .filter(stage -> stage.getType().equals(GenerateCanaryAnalysisResultStage.STAGE_TYPE)) .findFirst() .ifPresent(generateCanaryAnalysisResultStage -> Optional