/** * Makes sure that the given {@link StepContext} has all the context parameters this descriptor wants to see, * and if not, throw {@link MissingContextVariableException} indicating which variable is missing. */ public final void checkContextAvailability(StepContext c) throws MissingContextVariableException, IOException, InterruptedException { // TODO the order here is nondeterministic; should we pick the lexicographic first? Or extend MissingContextVariableException to take a Set<Class<?>> types? for (Class<?> type : getRequiredContext()) { Object v = c.get(type); if (v==null) throw new MissingContextVariableException(type); } }
/** * Makes sure that the given {@link StepContext} has all the context parameters this descriptor wants to see, * and if not, throw {@link MissingContextVariableException} indicating which variable is missing. */ public final void checkContextAvailability(StepContext c) throws MissingContextVariableException, IOException, InterruptedException { // TODO the order here is nondeterministic; should we pick the lexicographic first? Or extend MissingContextVariableException to take a Set<Class<?>> types? for (Class<?> type : getRequiredContext()) { Object v = c.get(type); if (v==null) throw new MissingContextVariableException(type); } }
@Override protected final T run() throws Exception { ws = getContext().get(FilePath.class); if (ws == null && isNotBlank(fileOrTextStep.getFile())) { throw new MissingContextVariableException(FilePath.class); } return doRun(); }
@Override protected final T run() throws Exception { ws = getContext().get(FilePath.class); if (ws == null && isNotBlank(fileOrTextStep.getFile())) { throw new MissingContextVariableException(FilePath.class); } return doRun(); }
Run build = getContext().get(Run.class); if (build == null) { throw new MissingContextVariableException(Run.class); throw new MissingContextVariableException(Launcher.class);
@Override protected Void run() throws Exception { if (step.getJson() == null) { throw new IllegalArgumentException(Messages.WriteJSONStepExecution_missingJSON(step.getDescriptor().getFunctionName())); } if (StringUtils.isBlank(step.getFile())) { throw new IllegalArgumentException(Messages.WriteJSONStepExecution_missingFile(step.getDescriptor().getFunctionName())); } if (isNotBlank(step.getFile()) && ws == null) { // Need a workspace if we are writing to a file. throw new MissingContextVariableException(FilePath.class); } FilePath path = ws.child(step.getFile()); if (path.isDirectory()) { throw new FileNotFoundException(Messages.JSONStepExecution_fileIsDirectory(path.getRemote())); } try (OutputStreamWriter writer = new OutputStreamWriter(path.write())) { if (step.getPretty() > 0) { writer.write(step.getJson().toString(step.getPretty())); } else { step.getJson().write(writer); } } return null; }