-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnotify-script
executable file
·53 lines (39 loc) · 973 Bytes
/
notify-script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
use Data::Dumper;
my %headers = ();
my $last_key;
while (my $l = <STDIN>) {
chomp $l;
last if $l eq '';
if ($l =~ /^ /) {
$l =~ s/^\s+//;
$headers{$last_key} .= " " . $l;
}
else {
my ($key, $value) = split(/\s*:\s*/, $l);
$last_key = $key;
$headers{$key} = $value;
}
}
my $subject = $headers{Subject};
my $to = $headers{To};
my $unstable = ($subject =~ m!(unstable|failed)! ? 1 : 0);
my $project;
if ($to =~ m!\bnotify\+([A-Z_]+)!) {
$project = $1;
$project =~ y!_! !;
}
else {
# Not interesting without a project name to show
exit(0);
}
exit(0) unless $subject && $to;
print "$project is ".($unstable ? "unstable" : "stable")."\n";
my $message = "$project FAIL";
my $ua = LWP::UserAgent->new();
foreach my $url ("http://sfo-ss-hachi.say:8081/") {
$ua->post($url, { active => $unstable, message => $message });
}