Post Process Script UCD
properties.put("Status", "Success");
//
// Evaluate the built-in exitCode property, which indicates the exit code
// of the script called by the plug-in step. Typically, if the value of
// the exitCode property is non-zero, the plug-in step failed.
//
if (properties.get("exitCode") != 0) {
properties.put("Status", "Failure");
}
else {
//
// Register a scanner to search for the text "error at line" in the log.
// The first argument is a regular expression.
//
// The second argument, an inline function, is invoked once for
// every line in the log output that matches the pattern. The "lineNumber"
// variable contains the line number where the match occurred, and the
// "line" variable is the full text of the line.
//
scanner.register("(?i)ERROR", function(lineNumber, line) {
//
// In this case, we build up an "Error" property which
// contains the text of all errors that are found. We find every
// line starting with "error at line" and add it to this list.
//
var errors = properties.get("Error");
if (errors == null) {
errors = new java.util.ArrayList();
}
errors.add(line);
properties.put("Status", "Failure");
});
scanner.register("The value is", function(lineNumber, line) {
var value = line.replace("The value is ", "");
properties.put("Value", value);
});
scanner.scan();
var errors = properties.get("Error");
if (errors == null) {
errors = new java.util.ArrayList();
}
properties.put("Error", errors.toString());
}