To improve communication among developers on your project team, you may want to create a trigger type that sends an e-mail message to team members whenever a developer completes a deliver operation. This section includes two scripts:
Script 1 creates a trigger type that fires at the end of a successful deliver operation.
Script 2 is the postoperation trigger action that sends e-mail messages to developers.
This script creates a postoperation trigger type that fires when a developer finishes a deliver operation, as represented by the deliver_complete opkind. The mktrtype command uses the -stream option to indicate that the trigger type applies only to deliver operations that target the specified integration stream.
# This is a Perl script to set up the triggertype
# for e-mail notification on deliver.
use Config;
# define platform-dependent arguments.
my $PVOBTAG;
if ($Config{'osname'} eq 'MSWin32') {
$PVOBTAG = '\cyclone_pvob';
$WCMD = '-execwin "ccperl
\\\\pluto\disk1\ucmtrig_examples\ex2\ex2_postop.pl"';
}
else {
$PVOBTAG = '/pvobs/cyclone_pvob';
$WCMD = '-execwin "ccperl
\\\\\\pluto\disk1\ucmtrig_examples\ex2\ex2_postop.pl"';
}
my $STREAM = "stream:P1_int\@$PVOBTAG";
my $TRTYPE = "trtype:ex2_postop\@$PVOBTAG";
my $UCMD = '-execunix "Perl
/net/pluto/disk1/ucmtrig_examples/ex2/ex2_postop.pl"';
print 'cleartool mktrtype -ucmobject -all -postop deliver_complete $WCMD $UCMD -stream $STREAM -nc $TRTYPE\Q;
This postoperation trigger action fires when a developer finishes delivering work to the integration stream. The script composes and sends an e-mail message to other developers on the project team telling them that a deliver operation has just finished. The script uses ClearCase environment variables to provide the following details about the deliver operation in the body of the message:
Project name
Development stream that delivered work
Integration stream that received delivered work
Integration activity created by the deliver operation
Activities delivered
Integration view used by deliver operation
# Perl script to send mail on deliver complete.
##################################################################
# Simple package to override the "open" method of Mail::Send so we
# can control the mailing mechanism.
package SendMail;
use Config;
use Mail::Send;
@ISA = qw(Mail::Send);
sub open {
my $me = shift;
my $how; # How to send mail
my $notused;
my $mailhost;
# On Windows use SMTP
if ($Config{'osname'} eq 'MSWin32') {
$how = 'smtp';
$mailhost = "localmail0.company.com";
}
# else use defaults supplied by Mail::Mailer
Mail::Mailer->new($how, $notused, $mailhost)->open($me);
}
#
##################################################################
# Main program
my @to = "developers\@company.com";
my $subject = "Delivery complete";
my $body = join '', ("\n",
"UCM Project: ", $ENV{CLEARCASE_PROJECT}, "\n",
"UCM source stream: ", $ENV{CLEARCASE_SRC_STREAM}, "\n",
"UCM destination stream: ", $ENV{CLEARCASE_STREAM}, "\n",
"UCM integration activity: ", $ENV{CLEARCASE_ACTIVITY}, "\n",
"UCM activities delivered: ", $ENV{CLEARCASE_DLVR_ACTS}, "\n",
"UCM view: ", $ENV{CLEARCASE_VIEW_TAG}, "\n"
);
my $msg = new SendMail(Subject=>$subject);
$msg->to(@to);
my $fh = $msg->open($me);
$fh->print($body);
$fh->close();
1; # return success
#
##################################################################
Feedback on the documentation in this site? We welcome any comments!
Copyright © 2001 by Rational Software Corporation. All rights reserved. |