You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Introduction to Custom Groovy Workflow Rules


Groovy scripting is available for quickly creating new pipeline modules without having to write Java Code and create a Jar for the component. Groovy scripts can do many things that a regular Java pipeline stage can do.

  • Groovy scripts are pooled and reused to minimize re-compiling of scripts
    • Therefore, all scripts are thread safe.

When Not to Use a Groovy Script

Anything Big or Complex - Because size and complexity can result in more opportunity for errors, it is recommended to code in Java where it is possible to do more careful unit testing with a Java based JUnit test bench.

More Information on Groovy

Groovy is a Java-based scripting language which compiles directly into Java byte code. It's advantages are that it runs very fast in the Java JVM and it has full access to all Java objects, classes, and methods.

Some useful Groovy Scripting links:

Variables

Your Groovy script will automatically have a number of variables predefined before the script is called. These variables can be used directly from your script (no special setup or imports or anything required).

VariableWhen AvailableDescription
jobalwaysJava Type = Job

References the job which is being procesed. You can use this variable to create new sub-jobs, check on job status, wait for sub-jobs, etc.

docalwaysJava Type = AspireObject

The AspireObject which holds all of the metadata for the current document being processed. This is the same as job.get() - the job's data object.

componentalwaysJava Type = StageImpl which is derived from ComponentImpl

This variable provides access to the component itself. This can be used for a variety of useful tasks, such as logging, accessing other components, getting Aspire Home, and turning relative paths to Aspire Home into absolute paths. Note that StageImpl extends ComponentImpl, where all of the most useful methods are located. This variable refers to the Workflow section which is running the rule, this sections can be: AfterScanWorkflow, AddUpdateWorkflow, PublishWorkflow, DeleteWorkflow or ErrorWorkflow

globalsalwaysJava Type = HashMap

This variable contains global variables you can pass between rules if required.

rulealwaysJava Type = Rule

This variable reference the rule that is being executed.


  • No labels