hydra-evaluator: Don't require $HYDRA_CONFIG

This commit is contained in:
Eelco Dolstra 2013-01-22 13:19:28 +01:00
parent fc39034772
commit f188fe5683
3 changed files with 41 additions and 40 deletions

View file

@ -9,7 +9,7 @@ use Hydra::Model::DB;
our @ISA = qw(Exporter);
our @EXPORT = qw(
getHydraHome getHydraConf txn_do
getHydraHome getHydraConfig txn_do
registerRoot getGCRootsDir gcRootFor
getPrimaryBuildsForView
getPrimaryBuildTotal
@ -23,10 +23,11 @@ sub getHydraHome {
}
sub getHydraConf {
sub getHydraConfig {
my $conf = $ENV{"HYDRA_CONFIG"} || (Hydra::Model::DB::getHydraPath . "/hydra.conf");
die "The HYDRA_CONFIG file ($conf) does not exist!\n" unless -f $conf;
return $conf;
return {} unless -f $conf;
my %config = new Config::General($conf)->getall;
return \%config;
}

View file

@ -24,21 +24,21 @@ STDOUT->autoflush();
my $db = Hydra::Model::DB->new();
my $config = getHydraConfig();
my %config = new Config::General(getHydraConf)->getall;
sub sendTwitterNotification {
my ($build) = @_;
return unless (defined $ENV{'TWITTER_USER'} && defined $ENV{'TWITTER_PASS'});
my $addURL = defined $config{'base_uri'};
my $addURL = defined $config->{'base_uri'};
my $jobName = $build->project->name . ":" . $build->jobset->name . ":" . $build->job->name;
my $status = $build->buildstatus == 0 ? "SUCCEEDED" : "FAILED";
my $system = $build->system;
my $duration = ($build->stoptime - $build->starttime) . " seconds";
my $url = $config{'base_uri'}."/build/".$build->id ;
my $url = $config->{'base_uri'}."/build/".$build->id ;
my $nt = Net::Twitter::Lite->new(
username => $ENV{'TWITTER_USER'},
@ -112,10 +112,10 @@ sub sendEmailNotification {
my $status = statusDescription($build->buildstatus);
my $baseurl = hostname_long ;
my $sender = $config{'notification_sender'} ||
my $sender = $config->{'notification_sender'} ||
(($ENV{'USER'} || "hydra") . "@" . $baseurl);
my $selfURI = $config{'base_uri'} || "http://localhost:3000";
my $selfURI = $config->{'base_uri'} || "http://localhost:3000";
sub showTime { my ($x) = @_; return strftime('%Y-%m-%d %H:%M:%S', localtime($x)); }
@ -446,8 +446,8 @@ if ($ENV{'HYDRA_TWITTER_TEST'}) {
my $build;
txn_do($db, sub {
$build = $db->resultset('Builds')->find($buildId);
die "build $buildId doesn't exist" unless defined $build;
die "build $buildId already done" if $build->finished;
die "build $buildId doesn't exist\n" unless defined $build;
die "build $buildId already done\n" if $build->finished;
if ($build->busy != 0 && $build->locker != getppid) {
die "build $buildId is already being built";
}

View file

@ -18,7 +18,7 @@ use Data::Dump qw(dump);
STDOUT->autoflush();
my $db = Hydra::Model::DB->new();
my %config = new Config::General(getHydraConf)->getall;
my $config = getHydraConfig();
sub fetchInputs {
@ -55,7 +55,7 @@ sub sendJobsetErrorNotification() {
my $projectName = $jobset->project->name;
my $jobsetName = $jobset->name;
my $sender = $config{'notification_sender'} ||
my $sender = $config->{'notification_sender'} ||
(($ENV{'USER'} || "hydra") . "@" . $url);
my $body = "Hi,\n"