@Override public String evaluate(Run<?, ?> run, FilePath workspace, TaskListener listener, String macroName) throws MacroEvaluationException, IOException, InterruptedException { InputStream inputStream = null; String result = ""; try { if (!StringUtils.isEmpty(script)) { inputStream = getFileInputStream(workspace, script, ".groovy"); result = executeScript(run, workspace, listener, inputStream); } else { inputStream = getFileInputStream(workspace, template, ".template"); result = renderTemplate(run, workspace, listener, inputStream); } } catch (FileNotFoundException e) { String missingScriptError = ""; if (!StringUtils.isEmpty(script)) { missingScriptError = generateMissingFile("Groovy Script", script); } else { missingScriptError = generateMissingFile("Groovy Template", template); } LOGGER.log(Level.SEVERE, missingScriptError); result = missingScriptError; } catch (GroovyRuntimeException e) { result = "Error in script or template: " + e.toString(); } finally { IOUtils.closeQuietly(inputStream); } return result; }