Implementing the server_master_trig Trigger

This section describes how to implement the server_master_trig trigger — what changes to make to it and how to enable it — to support gated streams. Note that this section describes aspects of trigger implementation that are unique to the server_master_trig trigger. See AccuRev Triggers for more information on AccuRev triggers and how to use them.

Step 1: Create a Non-expiring Session

The first thing to do in order to implement the server_master_trig trigger is to create a non-expiring session on the AccuRev Server by logging in to the AccuRev Server using accurev login -n <username> <password>. This is typically the admin user. Make a note of this user’s username as you will need include it in the server_master_trig trigger when you edit it.

This is a one-time procedure, and one which you might have already performed if you are already using server-side triggers in your AccuRev installation. See Trigger Script Execution and User Identities for more information.

Back to top

Step 2: Edit the server_master_trig Trigger

All sample triggers are installed to the examples directory where you installed AccuRev, c:\Program Files (x86)\AccuRev\examples\, for example. In order to edit the server_master_trig trigger:

  1. Make a copy of the server_master_trig trigger. Do not edit the server_master_trigger.pl file in the examples directory.

  2. Locate the following section in the trigger:

    # Unix Example
    # $::AccuRev = "/usr/accurev/bin/accurev";
    #
    # Windows Example
    $::AccuRev = "C:\\progra~1\\accurev\\bin\\accurev.exe";

    You use this section to configure the path of the AccuRev executable. Note that there are separate sections for UNIX and Windows users. The Windows section is uncommented by default.

    1. If necessary, comment out the Windows example and uncomment the UNIX example.

    2. Modify the path shown for $::AccuRev= as needed.

  3. Next, locate the following section in the trigger:

    # Unix Example
    # $ENV{'HOME'} = "/home/replace_with_username";
    #
    # Windows Example
    $ENV{'HOMEDRIVE'} = "c:";
    $ENV{'HOMEPATH'} = "\\Users\\replace_with_username"

    You use this section to configure the path to the home directory for the AccuRev user under which this trigger script will be run. Note that there are separate sections for UNIX and Windows users. The Windows section is uncommented by default.

    1. If necessary, comment out the Windows example and uncomment the UNIX example.

    2. Replace replace_with_username with the <username> you specified using the login -n command in the preceding section, Step 1: Create a Non-expiring Session.

  4. Finally, locate the following section in the trigger:

    ####################################################### 
    CUSTOMIZE ME
    ##### START: CUSTOM EXTERNAL ACTION #####

    You use this section of the server_master_trig trigger script to specify what it is you want the trigger to do. For example, you can use Perl to:

    • Write a simple condition that restricts promotes to a particular stream

    • Send email to an individual who is tasked with reviewing code before it can be promoted

    • Submit the changed files to kick off a build or run a test suite

  5. When you have finished modifying your copy of server_master_trig.pl, save your changes.

Back to top

Step 3: Put server_master_trig.pl on the Server

Once you have saved your changes to server_master_trig.pl:

  1. Create the a \storage\site_slice\triggers directory where you installed AccuRev if one does not already exist.

  2. Copy the modified server_master_trig.pl to storage\site_slice\triggers.

Back to top

Step 4: Windows Only: Create a Batch File for server_master_trig.pl

Once you have saved your changes to server_master_trig.pl, you need to create batch file if your AccuRev server is running on Windows. It is the batch file that AccuRev executes when elements are promoted into the gated stream.

  1. Navigate to the \storage\site_slice\triggers directory where you copied the server_master_trig trigger.

  2. At that location, run:

    pl2bat server_master_trig.pl
  3. This creates a batch file with the same name as the trigger (server_master_trig.bat).

Back to top