Integration → Creating Custom Plugins → The plugin.xml File → Step Post-Processing: <post-processing> Element
When a plugin step's <command> element finishes processing, the step's mandatory <post-processing> element is executed. The <post-processing> element optionally sets the step's output properties and error handling. The <post-processing> element can contain any valid JavaScript script (unlike the <command> element, <post-processing> scripts must be written in JavaScript). You can also provide your own scripts when defining the step in the Deployment Automation editor. Although not required, it is best practice for the scripts to be wrapped in a CDATA element.
You have access to a java.util.Properties variable called properties. The properties variable has several special properties: exitCode contains the process exit code, and Status contains the step's status. A Status value of Success means the step completed successfully.
Another available variable, scanner, can scan the step's output log on the agent and take actions depending on the results. The scanner variable may use the following public methods:
register(String regex, function call) registers a function to be called when the regular expression is matched.
addLOI(Integer lineNumber) adds a line to the lines of interest list, which are highlighted in the Log Viewer; implicitly called whenever scanner matches a line.
getLinesOfInterest() returns a java.util.List of lines of interest. This can also be used to remove lines.
scan() scans the log. Use after all regular expressions are registered.
The post-processing script can examine the step's output log and take actions based on the result. In the following code fragment, scanner.register() registers a string with a regular expression engine, then takes an action if the string is found. Once all strings are registered, it calls scanner.scan() on the step's output log line by line.
![CDATA[ properties.put("Status", "Success"); if (properties.get("exitCode") != 0) { properties.put("Status", "Failure"); } else { scanner.register("(?i)ERROR at line", function(lineNumber, line) { var errors = properties.get("Error"); if (errors == null) { errors = new java.util.ArrayList(); } errors.add(line); properties.put("Error", errors); properties.put("Status", "Failure"); }); . . . scanner.scan(); var errors = properties.get("Error"); if (errors == null) { errors = new java.util.ArrayList(); } properties.put("Error", errors.toString()); } ]]
You can also use post-processing scripts to set output properties that can then be used in other steps in the same process. This enables you to design complex workflows. Reference prior step output properties this way:
${p:stepName/propName}
Copyright © 2011–2019 Micro Focus or one of its affiliates. All rights reserved.