5 =head1 NAME $RCSfile: Activity.pl,v $
7 This trigger will update CCDB when activities are added or removed.
15 Andrew DeFaria <Andrew@ClearSCM.com>
23 Fri Mar 11 17:45:57 PST 2011
27 $Date: 2011/04/02 00:28:21 $
33 This trigger will update the CCDB when UCM activities are added or removed. It
34 is implemented as a post operation trigger on the mkactivity and rmactivity
35 Clearcase operations. It should be attached to all UCM vobs (i.e. pvobs) that
36 you wish CCDB to monitor. If using mktriggers.pl the trigger defintion is:
38 Trigger: CCDB_ACTIVITY
39 Description: Updates CCDB when activities are made or removed
41 Opkinds: -postop mkactivity,rmactivity,chactivity
55 $Data::Dumper::Indent = 0;
57 use lib $FindBin::Bin, "$FindBin::Bin/../lib", "$FindBin::Bin/../../lib";
62 my $VERSION = '$Revision: 1.6 $';
63 ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
65 triglog 'Starting trigger';
67 TriggerUtils::dumpenv;
69 my ($name, $pvob) = split /\@/, $ENV{CLEARCASE_ACTIVITY};
70 my ($stream) = split /\@/, $ENV{CLEARCASE_STREAM};
72 trigdie 'Activity name not known', 1
75 trigdie 'Pvob name not known', 1
78 $pvob = vobname $pvob;
80 my $CCDBService = CCDBService->new;
82 trigdie 'Unable to connect to CCDBService', 1
83 unless $CCDBService->connectToServer;
85 my ($err, $msg, $request);
87 triglog "CLEARCASE_OP_KIND: $ENV{CLEARCASE_OP_KIND}";
89 if ($ENV{CLEARCASE_OP_KIND} eq 'mkactivity') {
90 my $activity = Dumper {
93 type => $name !~ /^(deliver|rebase|integrate|revert|tlmerge)/i
98 # Squeeze out extra spaces
99 $activity =~ s/ = /=/g;
100 $activity =~ s/ => /=>/g;
102 $request = "AddActivity $activity";
104 triglog "Executing request: $request";
106 ($err, $msg) = $CCDBService->execute ($request);
108 trigdie "Activity: Unable to execute request: $request\n"
109 . join ("\n", @$msg), $err
114 my $streamActivityXref = Dumper {
120 # Squeeze out extra spaces
121 $streamActivityXref =~ s/ = /=/g;
122 $streamActivityXref =~ s/ => /=>/g;
124 $request = "AddStreamActivityXref $streamActivityXref"
125 } elsif ($ENV{CLEARCASE_OP_KIND} eq 'rmactivity') {
126 # Note: The delete on cascade option in the MySQL database for CCDB should
127 # handle clean up of any associated records like any stream_activity_xref
129 $request = "DeleteActivity $name $pvob";
130 } elsif ($ENV{CLEARCASE_OP_KIND} eq 'chactivity') {
131 # Need to move changeset items from $ENV{CLEARCASE_ACTIVITY} ->
132 # $ENV{CLEARCASE_TO_ACTIVITY}. I believe we will be called once for each
133 # element version since it says that CLEARCASE_ID_STR will be set and
134 # CLEARCASE_ID_STR uniquely identifies an element/version
135 triglog "Processing chactivity";
137 my ($fromActivity) = split /@/, $ENV{CLEARCASE_ACTIVITY};
139 my ($toActivity) = split /@/, $ENV{CLEARCASE_TO_ACTIVITY};
141 my $update = Dumper {
142 activity => $toActivity
145 # Squeeze out extra spaces
146 $update =~ s/ = /=/g;
147 $update =~ s/ => /=>/g;
149 my $elementName = $ENV{CLEARCASE_PN};
150 $elementName =~ s/\\/\//g;
151 $elementName = removeViewTag $elementName;
152 my $version = $ENV{CLEARCASE_ID_STR};
153 $version =~ s/\\/\//g;
155 $request = "UpdateChangeset $fromActivity $elementName ";
156 $request .= "$version $pvob $update";
159 triglog "Executing request: $request";
161 ($err, $msg) = $CCDBService->execute ($request);
163 trigdie "Activity: Unable to execute request: $request\n"
164 . join ("\n", @$msg), $err
169 $CCDBService->disconnectFromServer;
171 triglog 'Ending trigger';
177 =head1 CONFIGURATION AND ENVIRONMENT
179 DEBUG: If set then $debug is set to this level.
181 VERBOSE: If set then $verbose is set to this level.
183 TRACE: If set then $trace is set to this level.
191 L<Data::Dumper|Data::Dumper>
193 =head2 ClearSCM Perl Modules
205 <a href="http://clearscm.com/php/scm_man.php?file=CCDB/lib/CCDBService.pm">CCDBService</a><br>
206 <a href="http://clearscm.com/php/scm_man.php?file=CCDB/triggers/TriggerUtils.pm">TriggerUtils</a><br>
211 =head1 BUGS AND LIMITATIONS
213 There are no known bugs in this script
215 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
217 =head1 LICENSE AND COPYRIGHT
219 Copyright (c) 2011, ClearSCM, Inc. All rights reserved.