SDA - Using post-processing in a step or plug-in

1 Likes

 

Post-processing scripts are JavaScripts that can perform post-processing whenever a plugin step finishes execution.  They can be used in the creation of a new plug-in (specified within the plugin.xml file), or by adding a post-processing script to an individual process step.

1. Example of using within a plug-in:  (for a working example see the timestamp plugin).  Post-processing steps can be used within plugins to take action on criteria you specify.  For example, looking for specific output or error conditions, and setting properties as needed.  The following example is from the timestamp plugin, and demonstrates how to look specific outputs and store values in properties if found. (below refer to Figure 1. image).

 

  • Line 19 - note that the post-processing code resides in the post-processing section of the specific step.
  • Line 27 - Register a scanner to look for "Property_Name" in the output of the step.  If found, it will store the output line into a variable named "prop".  The substring code removes the "Property_Name" from the line (i.e. Property_Name=myProperty) results in "myProperty" being stored in the variable "prop".
  • Line 30 - Similar to above, register a scanner to look for "TimeStamp" in the output, and if found store the value of the line (minus the word TimeStamp) in a variable called "timestamp".
  • Line 34 - Create a new output property with a name equal to the "prop" variable, and a value equal to the "timestamp" variable.
Figure 1.

 

2. Example of using post-processing in a process step:  The following is an example of a post-process step used within a process step.  Each process step has "post-processing script" as a parameter, and they can be used to control process flow.  In the following example, there are specific process steps that we want to take if the current agent is a Network Deployment Manager, and the customer uses a naming convention of NDM for those SDA agents.  

Figure 2. shows the process logic, where the first step is a shell script that has a command of "echo ResourceName:${p:resource.name}".   This will simply echo the name of the resource out to the command shell.  

We can add the post-process script listed in Figure 3., which will check for the "NDM" string in the resource name and set a variable to true if found, and false otherwise.  The switch step then uses a property name of "GetResourceName/isNDM" which provides the true/false value we set from the post-processing step.

 

Figure 2

 

Figure 3

Tags:

Labels:

How To-Best Practice
Comment List
Anonymous
Related Discussions
Recommended