Script
Purpose¶
Call and list scripts.
Methods¶
Binding name: p6.script
call¶
Execute the named script and waits for it to complete. The current pipeline will be used by the called script.
Syntax
Map<String, TypedContent> p6.script.call(String scriptName)
Example
// Prepare pipeline variables for the sub-script
p6.pipeline.put('customerId', 'CUST-00712')
// Call the invoice generation script and inspect the result
def result = p6.script.call('MyApp.GenerateInvoice')
p6.log.debug 'Script returned ' + result.size() + ' pipeline entries'
start¶
Submits the named script for execution and returns its job id as a String. This method DOES NOT wait for the script execution to complete.
Syntax
String p6.script.start(String scriptName)
Tip
You can use the Platform6 job DSL to interact with the started script job using the returned job id
Example
// Start a long-running report generation script asynchronously
def jobId = p6.script.start('Reporting.MonthlyExport')
p6.log.info 'Started report generation, job ID: ' + jobId
exists¶
Checks if the given script exists.
Syntax
boolean p6.script.exists(String scriptName)
Example
// Guard against calling a script that may not be deployed
if (p6.script.exists('MyApp.ProcessCreditNote')) {
p6.script.call('MyApp.ProcessCreditNote')
} else {
p6.log.warn 'Credit note processing script not found'
}
list¶
Return a collection of all scripts names.
Syntax
List<String> p6.script.list()
Example
// List all scripts belonging to the MyApp application
p6.script.list().findAll { it.startsWith('MyApp.') }.each {
p6.log.debug 'MyApp script: ' + it
}