forked from lix-project/hydra
Pierre Bourdon
6189ba9c5e
This is implement in an extremely hacky way due to poor DBIx feature support. Ideally, what we'd need is a way to tell DBIx to ignore the errormsg column unless explicitly requested, and to automatically add a computed 'errormsg IS NULL' column in others. Since it does not support that, this commit instead hacks some support via method overrides while taking care to not break anything obvious.
68 lines
2.5 KiB
Perl
68 lines
2.5 KiB
Perl
use warnings;
|
|
use strict;
|
|
|
|
package CliRunners;
|
|
use Hydra::Helper::Exec;
|
|
our @ISA = qw(Exporter);
|
|
our @EXPORT = qw(
|
|
evalFails
|
|
evalSucceeds
|
|
runBuild
|
|
sendNotifications
|
|
);
|
|
|
|
sub evalSucceeds {
|
|
my ($jobset) = @_;
|
|
my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-eval-jobset", $jobset->project->name, $jobset->name));
|
|
$jobset->discard_changes({ '+columns' => {'errormsg' => 'errormsg'} }); # refresh from DB
|
|
if ($res) {
|
|
chomp $stdout; chomp $stderr;
|
|
utf8::decode($stdout) or die "Invalid unicode in stdout.";
|
|
utf8::decode($stderr) or die "Invalid unicode in stderr.";
|
|
print STDERR "Evaluation unexpectedly failed for jobset ".$jobset->project->name.":".$jobset->name.": \n".$jobset->errormsg."\n" if $jobset->errormsg;
|
|
print STDERR "STDOUT: $stdout\n" if $stdout ne "";
|
|
print STDERR "STDERR: $stderr\n" if $stderr ne "";
|
|
}
|
|
return !$res;
|
|
}
|
|
|
|
sub evalFails {
|
|
my ($jobset) = @_;
|
|
my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-eval-jobset", $jobset->project->name, $jobset->name));
|
|
$jobset->discard_changes({ '+columns' => {'errormsg' => 'errormsg'} }); # refresh from DB
|
|
if (!$res) {
|
|
chomp $stdout; chomp $stderr;
|
|
utf8::decode($stdout) or die "Invalid unicode in stdout.";
|
|
utf8::decode($stderr) or die "Invalid unicode in stderr.";
|
|
print STDERR "Evaluation unexpectedly succeeded for jobset ".$jobset->project->name.":".$jobset->name.": \n".$jobset->errormsg."\n" if $jobset->errormsg;
|
|
print STDERR "STDOUT: $stdout\n" if $stdout ne "";
|
|
print STDERR "STDERR: $stderr\n" if $stderr ne "";
|
|
}
|
|
return !!$res;
|
|
}
|
|
|
|
sub runBuild {
|
|
my ($build) = @_;
|
|
my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-queue-runner", "-vvvv", "--build-one", $build->id));
|
|
if ($res) {
|
|
utf8::decode($stdout) or die "Invalid unicode in stdout.";
|
|
utf8::decode($stderr) or die "Invalid unicode in stderr.";
|
|
print STDERR "Queue runner stdout: $stdout\n" if $stdout ne "";
|
|
print STDERR "Queue runner stderr: $stderr\n" if $stderr ne "";
|
|
}
|
|
return !$res;
|
|
}
|
|
|
|
sub sendNotifications() {
|
|
my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-notify", "--queued-only"));
|
|
if ($res) {
|
|
utf8::decode($stdout) or die "Invalid unicode in stdout.";
|
|
utf8::decode($stderr) or die "Invalid unicode in stderr.";
|
|
print STDERR "hydra notify stdout: $stdout\n" if $stdout ne "";
|
|
print STDERR "hydra notify stderr: $stderr\n" if $stderr ne "";
|
|
}
|
|
return !$res;
|
|
}
|
|
|
|
1;
|