Skip to content

Instantly share code, notes, and snippets.

@Siddhartha90
Created February 19, 2015 22:56
Show Gist options
  • Save Siddhartha90/9097c8392adec10b940f to your computer and use it in GitHub Desktop.
Save Siddhartha90/9097c8392adec10b940f to your computer and use it in GitHub Desktop.
Find Last Build Run
use strict;
use warnings;
use ElectricCommander;
# Turn off buffering
$| = 1;
my $ec = new ElectricCommander();
my $xpath = $ec->findObjects("job",
{maxIds => "1",
filter => [{propertyName => "projectName",
operator => "equals",
operand1 => "Commander"},
{propertyName => "liveSchedule",
operator => "equals",
operand1 => "main_linux_windows"},
{propertyName => "status",
operator => "equals",
operand1 => "completed"}],
sort => [{propertyName => "finish",
order => "descending"}]
});
my $lastBuild = $xpath->findvalue('//jobName')->value();
$ec->setProperty('/myJob/latestBuild', $lastBuild);
my $lastBuildStatus = $xpath->findvalue('//outcome')->value();
$ec->setProperty('/myJob/latestBuildOutcome', $lastBuildStatus);
my $lastBuildTime = $xpath->findvalue('//elapsedTime')->value();
my $temp= $lastBuildTime / 3600000;
my $time=substr($temp,0,index($temp,'.') + 1 + 2);
$ec->setProperty('/myJob/latestBuildElapsedTime', $time);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment