/*packahge*/ Object run(AbstractBuild<?, ?> build, BuildListener listener, @CheckForNull Launcher launcher) throws IOException, InterruptedException { Jenkins jenkins = Jenkins.getInstance(); if (jenkins == null) { throw new IllegalStateException("Jenkins instance is null - Jenkins is shutting down?"); } @Nonnull ClassLoader cl = jenkins.getPluginManager().uberClassLoader; // Use HashMap as a backend for Binding as Hashtable does not accept nulls Map<Object, Object> binding = new HashMap<Object, Object>(); binding.putAll(parseProperties(bindings)); binding.put("build", build); if (launcher != null) { binding.put("launcher", launcher); } if (listener != null) { binding.put("listener", listener); binding.put("out", listener.getLogger()); } try { return source.getSecureGroovyScript(build.getWorkspace(), build, listener).evaluate(cl, new Binding(binding)); } catch (IOException x) { throw x; } catch (InterruptedException x) { throw x; } catch (RuntimeException x) { throw x; } catch (Exception x) { throw new IOException(x); } }
Object result = null; try { result = script.evaluate(classLoader, binding); } catch (final RejectedAccessException e) { LOGGER.log(Level.WARNING, "Sandbox exception", e);
public void execute() throws Exception { Binding binding = new Binding(); if (build != null) { FilePath workspace = build.getWorkspace(); if (workspace != null && workspace.getRemote() != null) { binding.setVariable("workspace", new File(workspace.getRemote())); //NON-NLS } binding.setVariable("build", build); //NON-NLS } binding.setVariable("log", log); //NON-NLS binding.setVariable("out", log.getListener().getLogger()); //NON-NLS binding.setVariable("args", arguments); //NON-NLS ClassLoader classLoader = getClass().getClassLoader(); secureGroovyScript.evaluate(classLoader, binding); } }
groovyResult = script.evaluate(jenkins.getPluginManager().uberClassLoader, binding); } catch (Exception e) { throw new EnvInjectException("Failed to evaluate the script", e);