Class SecureGroovyScript
java.lang.Object
hudson.model.AbstractDescribableImpl<SecureGroovyScript>
org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript
- All Implemented Interfaces:
Describable<SecureGroovyScript>,Serializable
public final class SecureGroovyScript
extends AbstractDescribableImpl<SecureGroovyScript>
implements Serializable
Convenience structure encapsulating a Groovy script that may either be approved whole or sandboxed.
May be kept as the value of a field and passed in a
DataBoundConstructor parameter;
you must call configuring(org.jenkinsci.plugins.scriptsecurity.scripts.ApprovalContext) or a related method from your own constructor.
Use <f:property field="…"/> to configure it from Jelly.- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionSecureGroovyScript(String script, boolean sandbox) Deprecated.SecureGroovyScript(String script, boolean sandbox, List<ClasspathEntry> classpath) -
Method Summary
Modifier and TypeMethodDescriptionconfiguring(ApprovalContext context) To be called in your ownDataBoundConstructorwhen storing the field of this type.Convenience form ofconfiguring(org.jenkinsci.plugins.scriptsecurity.scripts.ApprovalContext)that callsApprovalContext.withCurrentUser()andApprovalContext.withItem(hudson.model.Item).evaluate(ClassLoader loader, groovy.lang.Binding binding) Deprecated.evaluate(ClassLoader loader, groovy.lang.Binding binding, TaskListener listener) Runs the Groovy script, using the sandbox if so configured.booleanbooleanvoidsetOldScript(String oldScript) Methods inherited from class hudson.model.AbstractDescribableImpl
getDescriptor
-
Constructor Details
-
SecureGroovyScript
@DataBoundConstructor public SecureGroovyScript(@NonNull String script, boolean sandbox, @CheckForNull List<ClasspathEntry> classpath) throws Descriptor.FormException - Throws:
Descriptor.FormException
-
SecureGroovyScript
@Deprecated public SecureGroovyScript(@NonNull String script, boolean sandbox) throws Descriptor.FormException Deprecated.- Throws:
Descriptor.FormException
-
-
Method Details
-
getScript
-
isSandbox
public boolean isSandbox() -
getClasspath
-
getOldScript
-
setOldScript
-
isScriptAutoApprovalEnabled
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean isScriptAutoApprovalEnabled() -
configuring
To be called in your ownDataBoundConstructorwhen storing the field of this type.- Parameters:
context- an approval context- Returns:
- this object
-
configuringWithKeyItem
-
configuringWithNonKeyItem
Convenience form ofconfiguring(org.jenkinsci.plugins.scriptsecurity.scripts.ApprovalContext)that callsApprovalContext.withCurrentUser()andApprovalContext.withItem(hudson.model.Item). -
evaluate
@Deprecated public Object evaluate(ClassLoader loader, groovy.lang.Binding binding) throws Exception Deprecated.- Throws:
Exception
-
evaluate
public Object evaluate(ClassLoader loader, groovy.lang.Binding binding, @CheckForNull TaskListener listener) throws Exception Runs the Groovy script, using the sandbox if so configured.- Parameters:
loader- a class loader for constructing the shell, such asPluginManager.uberClassLoader(will be augmented bygetClasspath()if nonempty)binding- Groovy variable bindingslistener- a way to print messages- Returns:
- the result of evaluating script using
GroovyShell.evaluate(String) - Throws:
Exception- in case of a general problemRejectedAccessException- in case of a sandbox issueUnapprovedUsageException- in case of a non-sandbox issueUnapprovedClasspathException- in case some unapproved classpath entries were requested
-
evaluate(ClassLoader, Binding, TaskListener)