use of org.jenkinsci.plugins.workflow.support.steps.input.InputStepExecution in project blueocean-plugin by jenkinsci.
the class PipelineStepVisitor method atomNode.
@Override
public void atomNode(@CheckForNull FlowNode before, @Nonnull FlowNode atomNode, @CheckForNull FlowNode after, @Nonnull ForkScanner scan) {
if (stageStepsCollectionCompleted && !PipelineNodeUtil.isSyntheticStage(currentStage)) {
return;
}
if (atomNode instanceof StepEndNode) {
this.closestEndNode = (StepEndNode) atomNode;
}
if (atomNode instanceof StepAtomNode && !PipelineNodeUtil.isSkippedStage(currentStage)) {
//if skipped stage, we don't collect its steps
long pause = PauseAction.getPauseDuration(atomNode);
chunk.setPauseTimeMillis(chunk.getPauseTimeMillis() + pause);
TimingInfo times = StatusAndTiming.computeChunkTiming(run, pause, atomNode, atomNode, after);
if (times == null) {
times = new TimingInfo();
}
NodeRunStatus status;
InputStep inputStep = null;
if (PipelineNodeUtil.isPausedForInputStep((StepAtomNode) atomNode, inputAction)) {
status = new NodeRunStatus(BlueRun.BlueRunResult.UNKNOWN, BlueRun.BlueRunState.PAUSED);
try {
for (InputStepExecution execution : inputAction.getExecutions()) {
FlowNode node = execution.getContext().get(FlowNode.class);
if (node != null && node.equals(atomNode)) {
inputStep = execution.getInput();
break;
}
}
} catch (IOException | InterruptedException | TimeoutException e) {
logger.error("Error getting FlowNode from execution context: " + e.getMessage(), e);
}
} else {
status = new NodeRunStatus(atomNode);
}
FlowNodeWrapper node = new FlowNodeWrapper(atomNode, status, times, inputStep, run);
if (PipelineNodeUtil.isPreSyntheticStage(currentStage)) {
preSteps.add(node);
} else if (PipelineNodeUtil.isPostSyntheticStage(currentStage)) {
postSteps.add(node);
} else {
if (!steps.contains(node)) {
steps.push(node);
}
}
stepMap.put(node.getId(), node);
//If there is closest block boundary, we capture it's error to the last step encountered and prepare for next block.
if (closestEndNode != null && closestEndNode.getError() != null) {
node.setBlockErrorAction(closestEndNode.getError());
//prepare for next block
closestEndNode = null;
}
}
}
use of org.jenkinsci.plugins.workflow.support.steps.input.InputStepExecution in project blueocean-plugin by jenkinsci.
the class PipelineStepImpl method submitInputStep.
@Override
public HttpResponse submitInputStep(StaplerRequest request) {
JSONObject body;
try {
body = JSONObject.fromObject(IOUtils.toString(request.getReader()));
} catch (IOException e) {
throw new ServiceException.UnexpectedErrorException(e.getMessage());
}
String id = body.getString(ID_ELEMENT);
if (id == null) {
throw new ServiceException.BadRequestExpception("id is required");
}
if (body.get(PARAMETERS_ELEMENT) == null && body.get(ABORT_ELEMENT) == null) {
throw new ServiceException.BadRequestExpception("parameters is required");
}
WorkflowRun run = node.getRun();
InputAction inputAction = run.getAction(InputAction.class);
if (inputAction == null) {
throw new ServiceException.BadRequestExpception("Error processing Input Submit request. This Run instance does not" + " have an InputAction.");
}
try {
InputStepExecution execution = inputAction.getExecution(id);
if (execution == null) {
throw new ServiceException.BadRequestExpception(String.format("Error processing Input Submit request. This Run instance does not" + " have an Input with an id of '%s'.", id));
}
//if abort, abort and return
if (body.get(ABORT_ELEMENT) != null && body.getBoolean(ABORT_ELEMENT)) {
return execution.doAbort();
}
//XXX: execution.doProceed(request) expects submitted form, otherwise we could have simply used it
preSubmissionCheck(execution);
Object o = parseValue(execution, JSONArray.fromObject(body.get(PARAMETERS_ELEMENT)), request);
HttpResponse response = execution.proceed(o);
for (PipelineInputStepListener listener : ExtensionList.lookup(PipelineInputStepListener.class)) {
listener.onStepContinue(execution.getInput(), run);
}
return response;
} catch (IOException | InterruptedException | TimeoutException e) {
throw new ServiceException.UnexpectedErrorException("Error processing Input Submit request." + e.getMessage());
}
}
Aggregations