]> snippets.scripts.mit.edu Git - Scripts/git/.git/blame - rt/Scrips/zephyr.pl
rt/Scrips/zephyr.pl: Path to zwrite changed
[Scripts/git/.git] / rt / Scrips / zephyr.pl
CommitLineData
1b73c3f9
AK
1my $class = 'scripts-test';
2my $instance_prefix = 'rt.';
eb85c42f 3my @zwrite = ('/usr/local/bin/zwrite', '-d', '-O', 'auto', '-c', $class);
1b73c3f9
AK
4
5# RT-to-Zephyr notification scrip
cfcaae12 6# http://snippets.scripts.mit.edu/gitweb.cgi/.git/blob/HEAD:/rt/Scrips/zephyr.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
02f6aac1 24# Condition: On Transaction
1b73c3f9
AK
25# Action: User Defined
26# Template: Global template: Blank
a7c202e3 27# Stage: TransactionCreate
1b73c3f9
AK
28# Custom action preparation code:
29# 1;
30# Custom action cleanup code:
31# [insert this code]
32
33sub send_notice {
34 my ($instance, $body, $extra) = @_;
35 open my $out, '|-', @zwrite, '-i', $instance, defined $extra ? ('-s', $extra) : ();
36 print $out $body;
37 close $out;
38};
39
40local $SIG{__DIE__} = sub {
41 my ($err) = @_;
42 $err =~ s/@/@@/g;
43 send_notice "${instance_prefix}error", "Internal error in Zephyr scrip:\n$err";
44};
45
efbc5742 46(my $id = $self->TransactionObj->Ticket) =~ s/@/@@/g;
1b73c3f9 47(my $description = $self->TransactionObj->Description) =~ s/@/@@/g;
efbc5742 48(my $subject = $self->TransactionObj->TicketObj->Subject) =~ s/@/@@/g;
1b73c3f9
AK
49
50send_notice "$instance_prefix$id", $description, $subject;
511;