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 aDataBoundConstructor
parameter; you must callconfiguring(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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SecureGroovyScript.DescriptorImpl
-
Constructor Summary
Constructors Constructor Description SecureGroovyScript(String script, boolean sandbox)
Deprecated.SecureGroovyScript(String script, boolean sandbox, List<ClasspathEntry> classpath)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description SecureGroovyScript
configuring(ApprovalContext context)
To be called in your ownDataBoundConstructor
when storing the field of this type.SecureGroovyScript
configuringWithKeyItem()
SecureGroovyScript
configuringWithNonKeyItem()
Convenience form ofconfiguring(org.jenkinsci.plugins.scriptsecurity.scripts.ApprovalContext)
that callsApprovalContext.withCurrentUser()
andApprovalContext.withItem(hudson.model.Item)
.Object
evaluate(ClassLoader loader, groovy.lang.Binding binding)
Deprecated.Object
evaluate(ClassLoader loader, groovy.lang.Binding binding, TaskListener listener)
Runs the Groovy script, using the sandbox if so configured.List<ClasspathEntry>
getClasspath()
String
getOldScript()
String
getScript()
boolean
isSandbox()
boolean
isScriptAutoApprovalEnabled()
void
setOldScript(String oldScript)
-
Methods inherited from class hudson.model.AbstractDescribableImpl
getDescriptor
-
-
-
-
Constructor Detail
-
SecureGroovyScript
@DataBoundConstructor public SecureGroovyScript(@NonNull String script, boolean sandbox, @CheckForNull List<ClasspathEntry> classpath)
-
SecureGroovyScript
@Deprecated public SecureGroovyScript(@NonNull String script, boolean sandbox)
Deprecated.
-
-
Method Detail
-
getScript
@NonNull public String getScript()
-
isSandbox
public boolean isSandbox()
-
getClasspath
@NonNull public List<ClasspathEntry> getClasspath()
-
getOldScript
public String getOldScript()
-
setOldScript
@DataBoundSetter public void setOldScript(String oldScript)
-
isScriptAutoApprovalEnabled
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean isScriptAutoApprovalEnabled()
-
configuring
public SecureGroovyScript configuring(ApprovalContext context)
To be called in your ownDataBoundConstructor
when storing the field of this type.- Parameters:
context
- an approval context- Returns:
- this object
-
configuringWithKeyItem
public SecureGroovyScript configuringWithKeyItem()
-
configuringWithNonKeyItem
public SecureGroovyScript 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
-
-