Class CpsScript
- java.lang.Object
-
- groovy.lang.GroovyObjectSupport
-
- groovy.lang.Script
-
- com.cloudbees.groovy.cps.SerializableScript
-
- org.jenkinsci.plugins.workflow.cps.CpsScript
-
- All Implemented Interfaces:
groovy.lang.GroovyObject
,Serializable
public abstract class CpsScript extends SerializableScript
The script of a workflow. EveryScript
we load in Pipeline execution derives from this subtype.- Author:
- Kohsuke Kawaguchi
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CpsScript()
Default constructor forCpsFlowExecution
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Run<?,?>
$build()
Run<?,?>
$buildNoException()
Object
evaluate(File file)
Object
evaluate(String script)
Object
getProperty(String property)
Object
invokeMethod(String name, Object args)
We use DSL here to try invoke the step implementation, if there is Step implementation found it's handled or it's an error.void
print(Object value)
void
printf(String format, Object value)
void
printf(String format, Object[] values)
void
println()
void
println(Object value)
protected Object
readResolve()
void
run(File file, String[] arguments)
Object
sleep(long arg)
Effectively overridesDefaultGroovyStaticMethods.sleep(Object, long)
so thatSleepStep
works even in the bare formsleep 5
.
-
-
-
Constructor Detail
-
CpsScript
public CpsScript() throws IOException
Default constructor forCpsFlowExecution
.- Throws:
IOException
-
-
Method Detail
-
invokeMethod
public final Object invokeMethod(String name, Object args)
We use DSL here to try invoke the step implementation, if there is Step implementation found it's handled or it's an error.sandbox security execution relies on the assumption that CpsScript.invokeMethod() is safe for sandboxed code. That means we cannot let user-written script override this method, hence the final.
- Specified by:
invokeMethod
in interfacegroovy.lang.GroovyObject
- Overrides:
invokeMethod
in classgroovy.lang.Script
-
getProperty
public Object getProperty(String property)
- Specified by:
getProperty
in interfacegroovy.lang.GroovyObject
- Overrides:
getProperty
in classgroovy.lang.Script
-
$build
@CheckForNull public Run<?,?> $build() throws IOException
- Throws:
IOException
-
$buildNoException
@CheckForNull public Run<?,?> $buildNoException()
-
evaluate
public Object evaluate(String script) throws org.codehaus.groovy.control.CompilationFailedException
- Overrides:
evaluate
in classgroovy.lang.Script
- Throws:
org.codehaus.groovy.control.CompilationFailedException
-
evaluate
public Object evaluate(File file) throws org.codehaus.groovy.control.CompilationFailedException, IOException
- Overrides:
evaluate
in classgroovy.lang.Script
- Throws:
org.codehaus.groovy.control.CompilationFailedException
IOException
-
run
public void run(File file, String[] arguments) throws org.codehaus.groovy.control.CompilationFailedException, IOException
- Overrides:
run
in classgroovy.lang.Script
- Throws:
org.codehaus.groovy.control.CompilationFailedException
IOException
-
readResolve
protected Object readResolve()
-
println
public void println()
- Overrides:
println
in classgroovy.lang.Script
-
print
public void print(Object value)
- Overrides:
print
in classgroovy.lang.Script
-
println
public void println(Object value)
- Overrides:
println
in classgroovy.lang.Script
-
printf
public void printf(String format, Object value)
- Overrides:
printf
in classgroovy.lang.Script
-
printf
public void printf(String format, Object[] values)
- Overrides:
printf
in classgroovy.lang.Script
-
sleep
public Object sleep(long arg)
Effectively overridesDefaultGroovyStaticMethods.sleep(Object, long)
so thatSleepStep
works even in the bare formsleep 5
.- See Also:
CpsClosure2.sleep(long)
-
-