]>
Commit | Line | Data |
---|---|---|
1b73c3f9 AK |
1 | my $class = 'scripts-test'; |
2 | my $instance_prefix = 'rt.'; | |
3 | my @zwrite = ('/usr/athena/bin/zwrite', '-d', '-O', 'auto', '-c', $class); | |
4 | ||
5 | # RT-to-Zephyr notification scrip | |
ad89b8ca | 6 | # http://snippets.scripts.mit.edu/gitweb.cgi/.git/blob/HEAD:/rt/zephyr-scrip.pl |
1b73c3f9 AK |
7 | # |
8 | # Copyright © 2010 Anders Kaseorg <andersk@mit.edu> | |
9 | # | |
10 | # This program is free software: you can redistribute it and/or modify | |
11 | # it under the terms of the GNU General Public License as published by | |
12 | # the Free Software Foundation, either version 2 of the License, or | |
13 | # (at your option) any later version. | |
14 | # | |
15 | # This program is distributed in the hope that it will be useful, but | |
16 | # WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 | # General Public License for more details. | |
19 | # | |
20 | # Usage: configure $class and $instance_prefix above, and create a | |
21 | # scrip as follows. | |
22 | # | |
23 | # Description: Send Zephyr | |
24 | # Condition: User Defined | |
25 | # Action: User Defined | |
26 | # Template: Global template: Blank | |
27 | # Stage: TrasnactionCreate | |
28 | # Custom condition: | |
29 | # 1; | |
30 | # Custom action preparation code: | |
31 | # 1; | |
32 | # Custom action cleanup code: | |
33 | # [insert this code] | |
34 | ||
35 | sub send_notice { | |
36 | my ($instance, $body, $extra) = @_; | |
37 | open my $out, '|-', @zwrite, '-i', $instance, defined $extra ? ('-s', $extra) : (); | |
38 | print $out $body; | |
39 | close $out; | |
40 | }; | |
41 | ||
42 | local $SIG{__DIE__} = sub { | |
43 | my ($err) = @_; | |
44 | $err =~ s/@/@@/g; | |
45 | send_notice "${instance_prefix}error", "Internal error in Zephyr scrip:\n$err"; | |
46 | }; | |
47 | ||
efbc5742 | 48 | (my $id = $self->TransactionObj->Ticket) =~ s/@/@@/g; |
1b73c3f9 | 49 | (my $description = $self->TransactionObj->Description) =~ s/@/@@/g; |
efbc5742 | 50 | (my $subject = $self->TransactionObj->TicketObj->Subject) =~ s/@/@@/g; |
1b73c3f9 AK |
51 | |
52 | send_notice "$instance_prefix$id", $description, $subject; | |
53 | 1; |