The <post-processing> Element

When a plug-in step's <command> element finishes processing, the step's mandatory <post-processing> element is executed. The <post-processing> element sets the step's output properties (step name/property name, see Serena Release Automation Properties) and provides error handling. The <post-processing> element can contain any valid JavaScript script (unlike the <command> element, <post-processing> scripts must be written in JavaScript). Users can also provide their own scripts when defining the step in the Serana Release Automation editor, see the section called “Post-Processing Scripts”. Although not required, it's recommended that scripts be wrapped in a CDATA element.

The <post-processing> element can examine the exit code of the tool invoked by the <command> element or the step's output log, and take actions based on the result. For example, Serana Release Automation sometimes uses a scanner object to scan the step's output on the agent (scanning occurs on the agent) and take actions dependent on scan results.

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.

 <![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());
      }
   ]]
        
loading table of contents...