private boolean isStrategy(Execution pipeline) { Trigger trigger = pipeline.getTrigger(); return "pipeline".equals(trigger.getType()) && trigger.isStrategy(); }
@SuppressWarnings("unchecked") public <E> List<E> getAll(Object key) { List<E> result = (List<E>) stage .ancestors() .stream() .filter(it -> it.getOutputs().containsKey(key)) .map(it -> it.getOutputs().get(key)) .collect(toList()); if (delegate.containsKey(key)) { result.add(0, (E) delegate.get(key)); } if (key.equals("artifacts")) { result.add((E) getTrigger().getArtifacts()); } else if (key.equals("resolvedExpectedArtifacts")) { result.add((E) getTrigger().getResolvedExpectedArtifacts()); } return result; } }
if (trigger != null && !trigger.getParameters().isEmpty()) { context.put("parameters", trigger.getParameters()); } else { if(!context.containsKey("parameters")) {
private Execution checkForCorrelatedExecution(Execution execution) { if (execution.getTrigger().getCorrelationId() == null) { return null; } Trigger trigger = execution.getTrigger(); try { Execution o = executionRepository.retrieveByCorrelationId( execution.getType(), trigger.getCorrelationId() ); log.info("Found pre-existing " + execution.getType() + " by correlation id (id: " + o.getId() + ", correlationId: " + trigger.getCorrelationId() + ")"); return o; } catch (ExecutionNotFoundException e) { // Swallow } return null; }
@Override public void taskGraph( @Nonnull Stage stage, @Nonnull TaskNode.Builder builder) { builder.withTask("suspendExecutionDuringTimeWindow", SuspendExecutionDuringTimeWindowTask.class); try { JitterConfig jitter = stage.mapTo("/restrictedExecutionWindow/jitter", JitterConfig.class); if (jitter.enabled && jitter.maxDelay > 0) { if (jitter.skipManual && stage.getExecution().getTrigger().getType().equals("manual")) { return; } long waitTime = ThreadLocalRandom.current().nextLong(jitter.minDelay, jitter.maxDelay + 1); stage.setContext(contextWithWait(stage.getContext(), waitTime)); builder.withTask("waitForJitter", WaitTask.class); } } catch (IllegalArgumentException e) { // Do nothing } }
public @Nonnull List<Artifact> getAllArtifacts(@Nonnull Execution execution) { // Get all artifacts emitted by the execution's stages; we'll sort the stages topologically, // then reverse the result so that artifacts from later stages will appear // earlier in the results. List<Artifact> emittedArtifacts = Stage.topologicalSort(execution.getStages()) .filter(s -> s.getOutputs().containsKey("artifacts")) .flatMap( s -> (Stream<Artifact>) ((List) s.getOutputs().get("artifacts")) .stream() .map(a -> a instanceof Map ? objectMapper.convertValue(a, Artifact.class) : a) ).collect(Collectors.toList()); Collections.reverse(emittedArtifacts); // Get all artifacts in the parent pipeline's trigger; these artifacts go at the end of the list, // after any that were emitted by the pipeline List<Artifact> triggerArtifacts = objectMapper.convertValue(execution.getTrigger().getArtifacts(), new TypeReference<List<Artifact>>() {}); emittedArtifacts.addAll(triggerArtifacts); return emittedArtifacts; }
String user = stage.getExecution().getTrigger().getUser();
}); if (execution.getTrigger().getCorrelationId() != null) { c.set( format("correlation:%s", execution.getTrigger().getCorrelationId()), execution.getId() );