String script = ContentBuilder.transformText(presendScript, context, getRuntimeMacros(context));
if (StringUtils.isNotBlank(script)) {
debug(context.getListener().getLogger(), "Executing pre-send script");
ClassLoader cl = Jenkins.getInstance().getPluginManager().uberClassLoader;
ScriptSandbox sandbox = null;
CompilerConfiguration cc = new CompilerConfiguration();
cc.addCompilationCustomizers(new ImportCustomizer().addStarImports(
"jenkins",
"jenkins.model",
"hudson",
"hudson.model"));
cl = expandClassLoader(cl, cc);
if (getDescriptor().isSecurityEnabled()) {
debug(context.getListener().getLogger(), "Setting up sandbox for pre-send script");
cc.addCompilationCustomizers(new SandboxTransformer());
sandbox = new ScriptSandbox();
}
Binding binding = new Binding();
binding.setVariable("build", context.getBuild());