nicolaken 2002/09/12 07:05:27
Added: gump/bin nag.pl
Removed: gump nag.pl
Log:
Moving script to a ./bin dir.
Revision Changes Path
1.1 jakarta-alexandria/gump/bin/nag.pl
Index: nag.pl
===================================================================
#!/usr/bin/perl
#
# Nag people and mailing lists upon particular build events,
# typically failures.
#
# @author Sam Ruby, Jon Stevens
# @see naglist for an example
#
# Note:
# Regep must be the last line of a group
# At most only one email will be generated to each project/email pair
($sec,$min,$hour,$mday,$mon,$year) = localtime;
$date=sprintf("%d-%2.2d-%2.2d", $year+1900, $mon+1, $mday);
$url = "http://jakarta.apache.org/builds/gump/$date";
$home = "/www/jakarta.apache.org/builds/gump/$date";
$sentto = {};
open (LIST, $ARGV[0]) or die "unable to open naglist $ARGV[0]";
foreach (<LIST>) {
next if /^#/; # ignore comments
next if /^\s*$/; # ignore blank lines
# parse simple data
$from = $1 if /From:\s*(.*?)\s*$/;
$mailto = $1 if /To:\s*(.*?)\s*$/;
$subject = $1 if /Subject:\s*(.*?)\s*$/;
# Project
if (/Project:\s*(.*?)\s*$/) {
$project = $1;
$sentto = {};
# read the entire file
open (FILE, "$home/$project.html");
$_ = join('',<FILE>);
close (FILE);
# extract just the stuff from inside the XMP tag
if (m! .* <XMP> \s* (.*) \s* </XMP> !xs) {
$pageData = $1;
} else {
$pageData = "";
}
}
# Regex
if (/Regex:\s*(.*?)\s*$/) {
# only nag once per project/mailto pair
next if $sentto->{$mailto};
if (eval "\$pageData =~ $1") {
$sentto->{$mailto}=1;
open ( EMAIL, "| /usr/sbin/sendmail -i -t");
print EMAIL "From: $from\n";
print EMAIL "To: $mailto\n";
print EMAIL "Subject: $subject\n\n";
print EMAIL "----------------------------------------------------\n";
print EMAIL "This email is autogenerated from the output from:\n";
print EMAIL "<$url/$project.html>\n";
print EMAIL "----------------------------------------------------\n\n";
if ($pageData) {
if (length($pageData)>50000) { # Apache's ezmlm limit is 100000
print EMAIL "Build results exceed maximum length.\n";
print EMAIL "Please see URL above for details.\n";
print EMAIL "Last 50 lines of build output follows.\n\n";
@lines = split("\n",$pageData);
$pageData = join("\n", splice(@lines, $#lines-50));
}
print EMAIL "$pageData";
} else {
print EMAIL "Build results missing. Please see URL above for details.";
}
close (EMAIL);
}
}
}
close (LIST);
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>