List<Execution> executions = executionRepository.retrievePipelinesForPipelineConfigId(canaryPipelineConfigId, executionCriteria).toList().toBlocking().single();
public @Nonnull List<Artifact> getArtifactsForPipelineId( @Nonnull String pipelineId, @Nonnull ExecutionCriteria criteria ) { Execution execution = executionRepository .retrievePipelinesForPipelineConfigId(pipelineId, criteria) .subscribeOn(Schedulers.io()) .toSortedList(startTimeOrId) .toBlocking() .single() .stream() .findFirst() .orElse(null); return execution == null ? Collections.emptyList() : getAllArtifacts(execution); }
/** * If {@code executionId} is set, it will be retrieved. Otherwise, {@code pipelineConfigId} will be used to find the * newest pipeline execution for that configuration. * @param executionId An explicit pipeline execution id. * @param pipelineConfigId A pipeline configuration id. Ignored if {@code executionId} is set. * @return The pipeline * @throws IllegalArgumentException if neither executionId or pipelineConfigId are provided * @throws ExecutionNotFoundException if no execution could be found */ public Execution retrievePipelineOrNewestExecution(@Nullable String executionId, @Nullable String pipelineConfigId) throws ExecutionNotFoundException { if (executionId != null) { // Use an explicit execution return executionRepository.retrieve(PIPELINE, executionId); } else if (pipelineConfigId != null) { // No executionId set - use last execution ExecutionRepository.ExecutionCriteria criteria = new ExecutionRepository.ExecutionCriteria().setPageSize(1); try { return executionRepository.retrievePipelinesForPipelineConfigId(pipelineConfigId, criteria) .toSingle() .toBlocking() .value(); } catch (NoSuchElementException e) { throw new ExecutionNotFoundException("No pipeline execution could be found for config id " + pipelineConfigId + ": " + e.getMessage()); } } else { throw new IllegalArgumentException("Either executionId or pipelineConfigId have to be set."); } }