KBEC-00082 - Iterating through properites, using xPath, to find 'error' or 'warning' values

Article ID:360032831792
1 minute readKnowledge base

Description

This article discusses how to find parameters and their values for a parent job step.

Solution

Because parameters are stored as properties on the job, use the getProperties command to access them.

Code

Use the following code:

use ElectricCommander;
my $ec = ElectricCommander->new();

my $xpath = $ec->getProperties( { jobId => $[/myJob/jobId], jobStepId => $ENV{COMMANDER_JOBSTEPID} } );
my $props = $xpath->find('//property');

foreach my $prop ($props->get_nodelist) {
    my $name = $prop->findvalue('propertyName');
    my $value = $prop->findvalue('value');
    if ($value eq 'error' or $value eq 'warning') {
        print "name=$name, value=$value\n";
    }
}