Use Email::MIME instead of Email::Simple

[?]
Nov 19, 2014, 1:44 PM
RX5IIZMT7AKE3SME2TON6HWE7BB2GNYV3KOKL3GLH4J7J2GEOO5AC

Dependencies

  • [2] KO7BXTVE Include # of failed builds in Subject
  • [3] 5M7DKCVI Fix typo.
  • [4] CG5Y56AE Fix uninitialized value warning
  • [5] 4AKMU4ZB Clean up user editing
  • [6] N22GPKYT * Put info about logs / build products in the DB.
  • [7] 5EQYVRWE Add a plugin mechanism
  • [8] 6BLUKEQ2 * Caching of "path" inputs, and fake a revision number for those.
  • [9] LDICTHWY Use Template::Toolkit to generate email messages
  • [10] SGRUPSLK Only send email notification of evaluation error when the evaluation error has changed. Fixes #121.
  • [11] LBNVQXUB * Build the /build stuff in a separate controller.
  • [12] FPK5LF53 * Put the project-related actions in a separate controller. Put the
  • [13] 7DWCXNC7 Use the new Nix Perl bindings
  • [14] 5SHCWE7X * Prevent repeated evaluation of a jobset with the same inputs. This
  • [15] RXVJFQ5A Evaluator cleanups
  • [16] FDE3BJAP * Refactoring.
  • [17] POPU2ATH * hydra_scheduler: use eval-jobs.
  • [18] CS7T2XFI
  • [19] 4IXVBLUI hack to try and prevent too many newlines
  • [20] WQXF2T3D hydra-evaluator: Don't require $HYDRA_CONFIG
  • [21] BLVQGJ4L Use OO-style plugins
  • [22] YFPZ46YK * hydra: added variant of build input type, 'build output (same system)' to allow better continous integration in one jobset for multiple system. it makes sure that the system of the build that is passed as input for a job has the same system as the job.
  • [23] H7CNGK4O * Log evaluation errors etc. in the DB.
  • [24] 7UJ5YV4V * Provide a channel for each project containing all the latest
  • [25] QDJRQIFF If multiple dependent builds fail, send a single email
  • [26] BXW62TGJ Emable overriding the email template.
  • [27] Z52T2BC4 Support passing a jobset evaluation as an input
  • [28] OK4P3AMK Remove the ability to add multiple jobset input alternatives
  • [29] N45RZUQ6 Reduce I/O in build listings by only fetching required columns
  • [30] TJK27WSB Open the DB using Hydra::Model::DB->new
  • [31] RWIBJ5L4 * Autoflush stdout.
  • [32] RPTSGIRC Eliminate duplicate getPreviousBuild functions
  • [33] LSZLZHJY Allow users to edit their own settings
  • [34] ODNCGFQ5 * Improved the navigation bar: don't include all projects (since that
  • [35] HQGXL4MX Add validation for project and jobset names
  • [36] ZDENAYQI * email notification of evaluation errors to project owner (if desired)
  • [37] SRQWC6YE Revert "Emable overriding the email template."
  • [38] E6SL7QRU Omit the system type if it's part of the job name
  • [39] PCKLFRT5 Support push notification of repository changes
  • [40] LMETCA7G Cleanup
  • [41] 7ZYBTNJJ revert unmeant previous change which caused errors to stay, even after successful evaluation of jobs
  • [42] 3XTHEUMP * Implemented the clone feature.
  • [43] NLJJZVHO * Use ->update({...}) properly.
  • [44] LZVO64YG Merge in the first bits of the API work
  • [45] SS4TZXNU Distinguish between permanent evaluation errors and transient input errors
  • [46] FHAVPTZ6 Hydra/23: added some X-headers with meta info in email notifications, added more descriptive status
  • [47] XJRJ4J7M Add user registration
  • [*] T4LLYESZ * Nix expression for building Hydra.
  • [*] 6K5PBUUN Use buildEnv to combine Hydra's Perl dependencies
  • [*] 36ZTCZ4F Add basic Persona support
  • [*] D5QIOJGP * Move everything up one directory.
  • [*] OOQ2D3KC * Refactoring: move fetchInput out of hydra_scheduler into a separate
  • [*] TULPZ62Y * Perform builds in parallel.

Change contents

  • edit in release.nix at line 102
    [50.734]
    [50.734]
    EmailMIME
  • edit in src/lib/Hydra/Controller/User.pm at line 11
    [6.435]
    [51.2]
    use Hydra::Helper::Email;
  • replacement in src/lib/Hydra/Controller/User.pm at line 283
    [5.1800][5.1800:1818]()
    sendEmail($c,
    [5.1800]
    [5.1818]
    sendEmail(
    $c->config,
  • replacement in src/lib/Hydra/Controller/User.pm at line 290
    [5.2091][5.2091:2127]()
    "With regards,\n\nHydra.\n"
    [5.2091]
    [5.2127]
    "With regards,\n\nHydra.\n",
    []
  • edit in src/lib/Hydra/Helper/CatalystUtils.pm at line 7
    [6.106][6.3989:4109]()
    use Email::Simple;
    use Email::Sender::Simple qw(sendmail);
    use Email::Sender::Transport::SMTP;
    use Sys::Hostname::Long;
  • edit in src/lib/Hydra/Helper/CatalystUtils.pm at line 18
    [6.1657][6.4110:4124]()
    sendEmail
  • edit in src/lib/Hydra/Helper/CatalystUtils.pm at line 188
    [6.540][6.11460:11462](),[6.11460][6.11460:11462](),[6.11462][6.4374:4432](),[6.4432][6.11462:11463](),[6.11462][6.11462:11463](),[6.11463][6.4433:4549](),[6.4549][6.11463:11464](),[6.11463][6.11463:11464](),[6.11464][6.4550:4858]()
    }
    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);
  • file addition: Email.pm (----------)
    [52.339]
    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;
  • edit in src/lib/Hydra/Plugin/EmailNotification.pm at line 3
    [6.65]
    [6.65]
    use utf8;
  • edit in src/lib/Hydra/Plugin/EmailNotification.pm at line 7
    [6.125][6.125:273](),[6.290][6.290:307]()
    use Email::Sender::Simple qw(sendmail);
    use Email::Sender::Transport::SMTP;
    use Email::Simple;
    use Email::Simple::Creator;
    use Sys::Hostname::Long;
    use File::Slurp;
  • edit in src/lib/Hydra/Plugin/EmailNotification.pm at line 10
    [6.34]
    [6.37]
    use Hydra::Helper::Email;
  • replacement in src/lib/Hydra/Plugin/EmailNotification.pm at line 16
    [6.477][6.0:307]()
    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
    [6.477]
    [6.756]
    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
  • replacement in src/lib/Hydra/Plugin/EmailNotification.pm at line 99
    [6.1349][6.1349:1431]()
    , baseurl => $self->{config}->{'base_uri'} || "http://localhost:3000"
    [6.1349]
    [6.1431]
    , baseurl => getBaseUrl($self->{config})
  • replacement in src/lib/Hydra/Plugin/EmailNotification.pm at line 113
    [6.2422][6.1751:1880]()
    my $sender = $self->{config}->{'notification_sender'} ||
    (($ENV{'USER'} || "hydra") . "@" . hostname_long);
    [6.2422]
    [6.3238]
    my $subject =
    showStatus($build) . ": Hydra job " . showJobName($build)
    . ($vars->{showSystem} ? " on " . $build->system : "")
    . (scalar @{$vars->{dependents}} > 0 ? " (and " . scalar @{$vars->{dependents}} . " others)" : "");
  • replacement in src/lib/Hydra/Plugin/EmailNotification.pm at line 118
    [6.3239][6.1881:2023](),[6.2023][6.3909:3910](),[6.4032][6.3909:3910](),[6.3909][6.3909:3910](),[6.5551][6.5551:5709](),[6.5709][2.0:300](),[2.300][6.2136:2192](),[6.525][6.2136:2192](),[6.2136][6.2136:2192](),[6.2192][6.5862:6176](),[6.5862][6.5862:6176](),[6.6176][6.5627:5628](),[6.5627][6.5627:5628](),[6.5628][6.6177:6429]()
    #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);
    }
    [6.3239]
    [6.5850]
    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
    ]);
  • edit in src/script/hydra-evaluator at line 10
    [53.10946]
    [6.688]
    use Hydra::Helper::Email;
  • edit in src/script/hydra-evaluator at line 13
    [6.48][6.248:396]()
    use Email::Sender::Simple qw(sendmail);
    use Email::Sender::Transport::SMTP;
    use Email::Simple;
    use Email::Simple::Creator;
    use Sys::Hostname::Long;
  • edit in src/script/hydra-evaluator at line 15
    [6.2451]
    [6.418]
    use Try::Tiny;
  • edit in src/script/hydra-evaluator at line 18
    [6.70]
    [54.914]
    STDERR->autoflush(1);
    binmode STDERR, ":encoding(utf8)";
  • replacement in src/script/hydra-evaluator at line 51
    [6.3184][4.0:64]()
    if (defined $errorMsg && $errorMsg ne ($prevError // "")) {
    [6.3184]
    [6.76]
    if (defined $errorMsg && $errorMsg ne ($prevError // "") || $ENV{'HYDRA_MAIL_TEST'}) {
  • edit in src/script/hydra-evaluator at line 60
    [6.612]
    [6.612]
    chomp $errorMsg;
  • edit in src/script/hydra-evaluator at line 65
    [6.1180][6.1010:1039]()
    my $url = hostname_long;
  • edit in src/script/hydra-evaluator at line 67
    [6.753][6.1180:1181](),[6.1180][6.1180:1181](),[6.1181][6.1317:1370](),[6.1370][6.1040:1091](),[6.805][6.1040:1091](),[6.1091][6.865:866](),[6.865][6.865:866]()
    my $sender = $config->{'notification_sender'} ||
    (($ENV{'USER'} || "hydra") . "@" . $url);
  • replacement in src/script/hydra-evaluator at line 69
    [6.904][3.0:94]()
    . "This is to let you know that Hydra jobset evaluation of $projectName:$jobsetName "
    [6.904]
    [6.997]
    . "This is to let you know that evaluation of the Hydra jobset ‘$projectName:$jobsetName’\n"
  • replacement in src/script/hydra-evaluator at line 76
    [6.1148][6.1148:1398](),[6.1398][6.1092:1225](),[6.1225][6.1371:1382](),[6.1237][6.51:70](),[6.1382][6.51:70](),[6.1409][6.51:70](),[6.70][6.1432:1439](),[6.1432][6.1432:1439](),[6.1439][6.71:100](),[6.100][6.1439:1440](),[6.1439][6.1439:1440](),[6.1440][6.1731:1794](),[6.1794][6.1496:1519](),[6.1496][6.1496:1519]()
    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);
    [6.1148]
    [6.1519]
    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";
    };