2. AccuRev® Command-Line Reference : mktrig

mktrig
activate a trigger in a depot
Usage
accurev mktrig [ -p <depot-name> ] [ pre-create-trig | pre-keep-trig |
pre-promote-trig | server-post-promote-trig ] <program-or-script>
Description
The mktrig command creates a trigger within a particular depot. A trigger can “fire” before or after certain AccuRev transactions occur. The following triggers are defined on a per-depot basis, affecting operations only with that particular depot:
pre-create-trig
fire on the client machine, before an add transaction
pre-keep-trig
fire on the client machine, before a keep transaction
pre-promote-trig
fire on the client machine, before a promote transaction
server-post-promote-trig
fire on the server machine, after a promote transaction
When a trigger fires, it executes the trigger program or trigger script that you specify in the mktrig command. The names of all elements involved in the transaction are passed to this program or script as part of a parameters file.
mktrig does not make a copy of the trigger script. It simply records the location at where AccuRev will look for the script when the trigger fires.
Note: The trigger script need not exist at the specified location when you issue the mktrig command. AccuRev doesn’t look for the script until the trigger fires.
A trigger fires exactly once per transaction. If you do a keep operation on 10 elements and there is a pre-keep trigger set, the trigger script will execute once, with an argument list containing all 10 element names. It is the script’s responsibility to process its entire argument list.
By acting once for the entire transaction, the script can abort a transaction if there is a problem with any element in the transaction, or you can send out a single email message with a list of all of the elements, instead of a separate message for each element in the transaction. For a transaction with 100 elements, that's a real benefit!
When the trigger script executes, its exit value should be 0 (success) or non-zero (failure). When a pre-operation trigger script fails, execution of the AccuRev operation is canceled.
Location of the Trigger Program or Script
The trigger script must be installed in a place that is accessible to everyone that will be using a depot with the trigger enabled. Separate copies of the script can be placed on each client machine. A better procedure is to place all scripts in a central, network-wide location that all client machines can “see” (UNIX/Linux mount or Windows network share). If triggers will fire on both Windows and UNIX/Linux machines, be sure to read Notes on Triggers in Multiple-Platform Environments on page 81 of the AccuRev Administrator’s Guide.
When a trigger fires, AccuRev looks for a script at the location you specify in the mktrig command. A pre-transaction trigger fires on the client machine:
A post-transaction trigger fires on the server machine:
Note: AccuRev uses a search path to locate the trigger script if you specify a simple name or a relative pathname for the script in the mktrig command (this is our recommendation); if you specify an absolute pathname for the script, no search path is involved.
The ‘server_preop_trig’ and ‘server_admin_trig’ Trigger Scripts
The triggers described above operate on a per-depot basis. For example, a pre-create-trig trigger might be activated in depot gizmo, but not in depot whammo. Two additional triggers execute on the AccuRev server machine:
The server_preop_trig script executes before the command is executed, and can cancel the command altogether. This is a per-depot trigger.
The server_admin_trig script executes after the command is executed. This script cannot cancel execution of the command. This trigger applies to AccuRev commands irrespective of which depot, if any, is being addressed. Note that the server_admin_trig script applies to all depots.
You enable these triggers not with the mktrig command, but by installing the trigger scripts at well-known locations. For details, see Server-Side Triggers on page 77 of the AccuRev Administrator’s Guide.
AccuWork Triggers
AccuRev’s issue management facility, AccuWork, also supports triggers. See server_dispatch_post on page 81 of the AccuRev Administrator’s Guide.
Options
-p <depot-name>
Specify the depot in which the trigger is to be enabled (default: the depot of the current workspace).
Examples
Execute Perl script elem-type.pl before each add transaction:
> accurev mktrig pre-create-trig /usr/local/triggers/elem-type.pl
Execute Perl script addheader.pl before each keep transaction:
> accurev mktrig pre-keep-trig /usr/local/triggers/addheader.pl
See Also
add, keep, rmtrig, show (triggers)
AccuRev Triggers on page 77 of the AccuRev Administrator’s Guide.

Borland