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 Post-Processing Scripts. Although not required, Serena recommendeds that scripts 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 (scanning occurs on the agent) and take actions depending on the results. scanner has several public methods:

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 use post-processing scripts to set output properties that can be used in other steps in the same process, which enables complex workflows. Reference prior step output properties this way:

${p:stepName/propName}