| Modifiers | Name | Description |
|---|---|---|
protected static java.lang.reflect.Method |
SCRIPT_SET_BINDING |
|
protected java.util.Map<MethodSignature, groovy.lang.Closure> |
allowedMethodCallbacks |
List of allowed methods with default interceptors. |
protected groovy.util.GroovyScriptEngine |
gse |
Internal script engine |
protected LibraryLoader |
libLoader |
Loader for shared global libraries |
protected java.lang.Object |
loadInterceptor |
Method interceptor for method 'load' to load scripts via encapsulated GroovyScriptEngine |
java.lang.Object |
methodInterceptor |
Method interceptor for any method called in executing script. |
protected java.lang.Object |
parallelInterceptor |
Method interceptor for method 'parallel' |
| Type | Name and description |
|---|---|
java.lang.ClassLoader |
baseClassloaderClassloader to instantiate scripts |
java.lang.String |
baseScriptRootBase path for script roots. |
java.util.List<MethodCall> |
callStackStack of method calls of scripts loaded by this helper |
java.util.Map<java.lang.String, java.lang.String> |
importsDefault imports for scripts loaded by this helper |
java.util.Map<java.lang.String, LibraryConfiguration> |
librariesGlobal Shared Libraries to be loaded with scripts if necessary |
java.lang.Object |
libraryResourceInterceptorMethod interceptor for 'libraryResource' in Shared libraries The resource from shared library should have been added to the url classloader in advance |
java.lang.Object |
methodMissingInterceptorMethod for calling custom allowed methods |
java.lang.Class |
scriptBaseClassBase class for instantiated scripts |
java.lang.String |
scriptExtensionExtension for script files. |
java.lang.String[] |
scriptRootsSearch paths for scripts |
| Constructor and description |
|---|
PipelineTestHelper
() |
PipelineTestHelper
(java.lang.String[] scriptRoots, java.lang.String scriptExtension, java.lang.Class scriptBaseClass, java.util.Map<java.lang.String, java.lang.String> imports, java.lang.ClassLoader baseClassloader, java.lang.String baseScriptRoot) |
| Type | Name and description |
|---|---|
java.lang.Object |
callClosure(groovy.lang.Closure closure, java.lang.Object[] args = null)Call closure by handling spreading of parameter default values |
java.lang.Object |
callIfClosure(java.lang.Object closure, java.lang.Object currentResult) |
protected java.lang.Object |
callMethod(groovy.lang.MetaMethod method, java.lang.Object delegate, java.lang.Object[] args)Call given method on delegate object with args parameters |
void |
clearCallStack()Clear call stack |
protected Map.Entry<MethodSignature, groovy.lang.Closure> |
getAllowedMethodEntry(java.lang.String name, java.lang.Object... args)Search for the allowed method entry |
java.lang.Object |
getMethodInterceptor() |
java.lang.Object |
getMethodMissingInterceptor() |
PipelineTestHelper |
init() |
protected boolean |
isInitialized()@return true if internal GroovyScriptEngine is set |
protected boolean |
isMethodAllowed(java.lang.String name, java.lang.Object args)@param name method name |
groovy.lang.Script |
loadScript(java.lang.String name)Load the script with name and empty binding, returning the Script |
groovy.lang.Script |
loadScript(java.lang.String scriptName, groovy.lang.Binding binding)Load the script with given binding context without running, returning the Script |
long |
methodCallCount(java.lang.String name)Count the number of calls to the method with name |
void |
registerAllowedMethod(java.lang.String name, java.util.List<java.lang.Class> args = [], groovy.lang.Closure closure)@param name method name |
void |
registerAllowedMethod(MethodSignature methodSignature, groovy.lang.Closure closure)Register a callback implementation for a method Calls from the loaded scripts to allowed methods will call the given implementation Null callbacks will only log the call and do nothing |
void |
registerAllowedMethod(MethodSignature methodSignature, java.util.function.Function callback)@param methodSignature |
void |
registerAllowedMethod(MethodSignature methodSignature, java.util.function.Consumer callback)@param methodSignature |
protected void |
registerMethodCall(java.lang.Object target, int stackDepth, java.lang.String name, java.lang.Object... args)Register method call to call stack |
void |
registerSharedLibrary(LibraryConfiguration libraryDescription)Register library description See LibraryConfiguration for its description |
java.lang.Object |
runScript(java.lang.String scriptName, groovy.lang.Binding binding)Load and run the script, returning the result value; |
java.lang.Object |
runScript(java.lang.String scriptName)Load and run the script, returning the result value; |
java.lang.Object |
runScript(groovy.lang.Script script)Run the given script object |
protected java.lang.Object |
runScriptInternal(groovy.lang.Script script)Run the script |
protected void |
setGlobalVars(groovy.lang.Binding binding)Sets global variables defined in loaded libraries on the binding |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
List of allowed methods with default interceptors. Complete this list in need with registerAllowedMethod
Internal script engine
Loader for shared global libraries
Method interceptor for method 'load' to load scripts via encapsulated GroovyScriptEngine
Method interceptor for any method called in executing script. Calls are logged on the call stack.
Method interceptor for method 'parallel'
Classloader to instantiate scripts
Base path for script roots. Usually the path to the project.
Stack of method calls of scripts loaded by this helper
Default imports for scripts loaded by this helper
Global Shared Libraries to be loaded with scripts if necessary
Method interceptor for 'libraryResource' in Shared libraries The resource from shared library should have been added to the url classloader in advance
Method for calling custom allowed methods
Base class for instantiated scripts
Extension for script files. Ex. jenkins
Search paths for scripts
Call closure by handling spreading of parameter default values
closure - to callargs - array of arguments passed to this closure call. Is null by default.Call given method on delegate object with args parameters
method - method to calldelegate - object of the method callargs - method call parametersClear call stack
Search for the allowed method entry name - method nameargs - parameter objects
name - method nameargs - parameter objectsLoad the script with name and empty binding, returning the Script
name - path of the scriptLoad the script with given binding context without running, returning the Script
Count the number of calls to the method with name
name - method name
name - method nameargs - parameter typesclosure - method implementation, can be nullRegister a callback implementation for a method Calls from the loaded scripts to allowed methods will call the given implementation Null callbacks will only log the call and do nothing
methodSignature - method signatureclosure - method implementation, can be null
Register method call to call stack
target - target objectstackDepth - depth in stackname - method nameargs - method argumentsRegister library description See LibraryConfiguration for its description
libraryDescription - to addLoad and run the script, returning the result value;
Load and run the script, returning the result value;
Run the given script object
Script - objectRun the script
Sets global variables defined in loaded libraries on the binding
Groovy Documentation