From c4bddfb94339da5f76f51dcfae86beb38b586351 Mon Sep 17 00:00:00 2001 From: "cls%seawood.org" Date: Tue, 23 Jan 2007 19:38:47 +0000 Subject: [PATCH] Add option to mail $FailedBuildAdministrator upon initial build failure. Bug #206665 r=preed --- tools/tinderbox/build-seamonkey-util.pl | 33 ++++++++++++++++++++++++- tools/tinderbox/tinder-config.pl | 2 ++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/tools/tinderbox/build-seamonkey-util.pl b/tools/tinderbox/build-seamonkey-util.pl index 18526ae2ca6d..14f09564074b 100644 --- a/tools/tinderbox/build-seamonkey-util.pl +++ b/tools/tinderbox/build-seamonkey-util.pl @@ -24,7 +24,7 @@ use Config; # for $Config{sig_name} and $Config{sig_num} use File::Find (); use File::Copy; -$::UtilsVersion = '$Revision: 1.343 $ '; +$::UtilsVersion = '$Revision: 1.344 $ '; package TinderUtils; @@ -730,6 +730,35 @@ sub mail_build_started_message { unlink "$msg_log"; } +sub mail_build_failed_message { + my ($start_time) = @_; + + return if (!defined($Settings::FailedBuildAdministrator) or + "$Settings::FailedBuildAdministrator" eq ""); + + my $msg_log = "build_failed_msg.tmp"; + open LOG, ">", $msg_log; + + PrintUsage() if $Settings::BuildTree =~ /^\s+$/i; + + my $platform = $Settings::OS =~ /^WIN/ ? 'windows' : 'unix'; + + print_log "Subject: tinderbox bustage: $Settings::BuildName"; + print_log "\n"; + print_log "Tinderbox tree: $Settings::BuildName has failed to build at $start_time\n"; + print_log "\n"; + + close LOG; + + if ($Settings::blat ne "" && $Settings::use_blat) { + system("$Settings::blat $msg_log -to $Settings::FailedBuildAdministrator"); + } else { + system "$Settings::mail " . + "$Settings::FailedBuildAdministrator < $msg_log"; + } + unlink "$msg_log"; +} + sub encode_log { my $input_file = shift; my $output_file = shift; @@ -1208,6 +1237,8 @@ sub BuildIt { # Increment failure count if we failed. if ($build_status eq 'busted') { $build_failure_count++; + mail_build_failed_message($start_time) if + ($build_failure_count == 1 && $Settings::ReportFailedStatus); } else { $build_failure_count = 0; } diff --git a/tools/tinderbox/tinder-config.pl b/tools/tinderbox/tinder-config.pl index ec5a1fe2e200..ffe7d1f833f1 100644 --- a/tools/tinderbox/tinder-config.pl +++ b/tools/tinderbox/tinder-config.pl @@ -22,6 +22,7 @@ #- PLEASE FILL THIS IN WITH YOUR PROPER EMAIL ADDRESS #$BuildAdministrator = "$ENV{USER}\@$ENV{HOST}"; #$BuildAdministrator = ($ENV{USER} || "cltbld") . "\@" . ($ENV{HOST} || "dhcp"); +#$FailedBuildAdministrator = $BuildAdministrator; #- You'll need to change these to suit your machine's needs #$DisplayServer = ':0.0'; @@ -31,6 +32,7 @@ #$BuildDepend = 1; # Depend or Clobber #$BuildDebug = 0; # Debug or Opt (Darwin) #$ReportStatus = 1; # Send results to server, or not +#$ReportFailedStatus= 1; # Send email report of initial build failure #$ReportFinalStatus = 1; # Finer control over $ReportStatus. #$UseTimeStamp = 1; # Use the CVS 'pull-by-timestamp' option, or not #$BuildOnce = 0; # Build once, don't send results to server