@RequirePOST public JSON doCheckScriptCompile(@AncestorInPath Item job, @QueryParameter String value) { if (!job.hasPermission(Job.CONFIGURE)) { return CpsFlowDefinitionValidator.CheckStatus.SUCCESS.asJSON(); } try { CpsGroovyShell trusted = new CpsGroovyShellFactory(null).forTrusted().build(); new CpsGroovyShellFactory(null).withParent(trusted).withSandbox(true).build().getClassLoader().parseClass(value); } catch (CompilationFailedException x) { return JSONArray.fromObject(CpsFlowDefinitionValidator.toCheckStatus(x).toArray()); } return CpsFlowDefinitionValidator.CheckStatus.SUCCESS.asJSON(); // Approval requirements are managed by regular stapler form validation (via doCheckScript) }