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QC
E6SL7QRU22NGMN7XNOGEKXRHHZO25BQR6T3MCHECRIX37H7F5MGQC
OOQ2D3KCLFPYNAN253PHWLBQMB6OMO2KYQWQXLTP65SQAYZWQ5LAC
TJK27WSBFOM6LKVCSA7LTTCWUGB4O2AL22PNIDQXS4BFOFCISH2QC
N22GPKYTOLZLBGTGDATQDVZ4R5APZEAOIA7L32X4UXBH4XNI7MWAC
RWIBJ5L4MDV4XQIQXBB45RBVAK2IAK3IMP37YUX2SHW7YDKDAAXAC
ZDENAYQI5DRRNUIDVKUGC45NK6C4ZFUL5FYMACTRZOCYQXPMY63QC
YFPZ46YK4BOI6VH2H3F757UEGEYONURUAEDAYEIBLRY33PLSSO4AC
TULPZ62YXEHXUWGBZMLCLYILEXPQS5ADPT22574BIRFU4CZMBSKAC
H7CNGK4OJNRYZQGPLBGR72DULLEPFQ5UISF5J24D7IMA7SYW5LGQC
SGRUPSLKIPDS6MNDCHTZB3K2IC5ALUNNM3OKQWW4AAU7KXGQPUJAC
FDE3BJAPDEP3BYT5A5GEGLNXPPZLA2KTGXB4ZNYRP4LJ7IFRKYXAC
FHAVPTZ6GYCZMMPIJN2VPGBACK66NENWCFJMTAOW6464WNCJPVOQC
WQXF2T3DFC2K72OVX46TUQ4IMZNJ5BSBQ7L7AVI7QL54DXCBEKLQC
4IXVBLUICBCBNLPJ23NDC7UKEPFN53HWVNZXK5HR23JMZEM2GUBAC
RXVJFQ5AV3WME4HDVBPSRCALQTXROT4KQPOQVO6KTWTBNZIZZGPAC
}
sub sendEmail {
my ($c, $to, $subject, $body) = @_;
my $sender = $c->config->{'notification_sender'} ||
(($ENV{'USER'} || "hydra") . "@" . hostname_long);
my $email = Email::Simple->create(
header => [
To => $to,
From => "Hydra <$sender>",
Subject => $subject
],
body => $body
);
print STDERR "Sending email:\n", $email->as_string if $ENV{'HYDRA_MAIL_TEST'};
sendmail($email);
package Hydra::Helper::Email;
use strict;
use Exporter 'import';
use Email::Sender::Simple qw(sendmail);
use Email::MIME;
use File::Slurp;
use Sys::Hostname::Long;
our @EXPORT = qw(sendEmail getBaseUrl);
sub sendEmail {
my ($config, $to, $subject, $body, $extraHeaders) = @_;
my $url = getBaseUrl($config);
my $sender = $config->{'notification_sender'} // (($ENV{'USER'} // "hydra") . "@" . $url);
my @headers = (
To => $to,
From => "Hydra Build Daemon <$sender>",
Subject => $subject,
'X-Hydra-Instance' => $url, @{$extraHeaders}
);
my $email = Email::MIME->create(
attributes => {
encoding => 'quoted-printable',
charset => 'UTF-8',
},
header_str => [ @headers ],
body_str => $body
);
print STDERR "sending email:\n", $email->as_string if $ENV{'HYDRA_MAIL_TEST'};
if (defined $ENV{'HYDRA_MAIL_SINK'}) {
# For testing, redirect all mail to a file.
write_file($ENV{'HYDRA_MAIL_SINK'}, { append => 1 }, $email->as_string . "\n");
} else {
sendmail($email, { from => $sender });
}
}
sub getBaseUrl {
my ($config) = @_;
return $config->{'base_uri'} // "http://" . hostname_long . ":3000";
}
1;
The status of Hydra job [% showJobName(build) %] [% IF showSystem %](on [% build.system %]) [% END %][% IF prevBuild && build.buildstatus != prevBuild.buildstatus %]has changed from "[% showStatus(prevBuild) %]" to "[% showStatus(build) %]"[% ELSE %]is "[% showStatus(build) %]"[% END %]. For details, see
The status of Hydra job ‘[% showJobName(build) %]’ [% IF showSystem %](on [% build.system %]) [% END %][% IF prevBuild && build.buildstatus != prevBuild.buildstatus %]has changed from "[% showStatus(prevBuild) %]" to "[% showStatus(build) %]"[% ELSE %]is "[% showStatus(build) %]"[% END %]. For details, see
my $sender = $self->{config}->{'notification_sender'} ||
(($ENV{'USER'} || "hydra") . "@" . hostname_long);
my $subject =
showStatus($build) . ": Hydra job " . showJobName($build)
. ($vars->{showSystem} ? " on " . $build->system : "")
. (scalar @{$vars->{dependents}} > 0 ? " (and " . scalar @{$vars->{dependents}} . " others)" : "");
#my $loglines = 50;
#my $logtext = logContents($build->drvpath, $loglines);
#$logtext = removeAsciiEscapes($logtext);
my $email = Email::Simple->create(
header => [
To => $to,
From => "Hydra Build Daemon <$sender>",
Subject =>
showStatus($build) . ": Hydra job " . showJobName($build)
. ($vars->{showSystem} ? " on " . $build->system : "")
. (scalar @{$vars->{dependents}} > 0 ? " (and " . scalar @{$vars->{dependents}} . " others)" : ""),
'X-Hydra-Instance' => $vars->{baseurl},
'X-Hydra-Project' => $build->project->name,
'X-Hydra-Jobset' => $build->jobset->name,
'X-Hydra-Job' => $build->job->name,
'X-Hydra-System' => $build->system
],
body => "",
);
$email->body_set($body);
if (defined $ENV{'HYDRA_MAIL_SINK'}) {
# For testing, redirect all mail to a file.
write_file($ENV{'HYDRA_MAIL_SINK'}, { append => 1 }, $email->as_string . "\n");
} else {
sendmail($email);
}
sendEmail(
$self->{config}, $to, $subject, $body,
[ 'X-Hydra-Project' => $build->project->name,
, 'X-Hydra-Jobset' => $build->jobset->name,
, 'X-Hydra-Job' => $build->job->name,
, 'X-Hydra-System' => $build->system
]);
my $email = Email::Simple->create(
header => [
To => $jobset->project->owner->emailaddress,
From => "Hydra Build Daemon <$sender>",
Subject => "Hydra $projectName:$jobsetName evaluation error",
'X-Hydra-Instance' => $url,
'X-Hydra-Project' => $projectName,
'X-Hydra-Jobset' => $jobsetName
],
body => ""
);
$email->body_set($body);
print STDERR $email->as_string if $ENV{'HYDRA_MAIL_TEST'};
sendmail($email);
try {
sendEmail(
$config,
$jobset->project->owner->emailaddress,
"Hydra $projectName:$jobsetName evaluation error",
$body,
[ 'X-Hydra-Project' => $projectName
, 'X-Hydra-Jobset' => $jobsetName
]);
} catch {
warn "error sending email: $_\n";
};