Perforce Command Reference:   [Index] [Prev] [Next]


p4 triggers

Synopsis

Edit a list of scripts to be run conditionally whenever changelists are submitted.

Syntax

p4 [g-opts] triggers
p4 [g-opts] triggers -i
p4 [g-opts] triggers -o

Description

A pre-submit trigger is a user-written script that Perforce has been told to run whenever particular files are submitted in a changelist. If the script returns a value of 0, the submit continues; if it returns any other value, the submit fails.

Triggers are run in the order listed in the table; if one trigger script fails, subsequent trigger scripts are not run. Even when a trigger script succeeds, the submit may fail because of subsequent triggers, or for other reasons. Thus, pre-submit triggers should be used only for validation, and should not perform operations that are dependent on the successful completion of the submit. If this is necessary, create a daemon instead.

To use the same trigger script with multiple file patterns, list the same trigger multiple times in the trigger table. Exclusionary mappings can be provided to exclude files from activating the trigger script; in this case, the order of the trigger entries matters, just as it does when exclusionary mappings are used in views (see the Examples section, below).

If a particular trigger name is listed multiple times, only the script corresponding to the first use of the trigger name is activated.

Form Fields

The p4 triggers form contains a single field, called Triggers. Each row in the table has three values; these values are:

Column Description

Trigger Name

The name of the trigger; an arbitrary string.

File Pattern

A file pattern in depot syntax. When a user submits a changelist that contains any files that match this file pattern, the script linked to this trigger will be run.

Trigger Script

A script located on the Perforce server. Arguments can be passed to this script; a list of valid arguments is provided in the Usage Notes, below. The script and its arguments should be quoted.

Options

-i Reads the trigger table from standard input without invoking the user's editor.
-o Writes the trigger table to standard output without invoking the user's editor.
g_opts See global options section.

Usage Notes

Can File Arg Use
Revision Specifier?
Can File Arg
Use Revision Range?
Minimal
Access Level Required
<NA> <NA> super

Examples

Suppose that the trigger table consists of the following entries:

trig1 //depot/bar/... "/usr/bin/s1.pl %changelist%"
trig2 //depot/bar/foo "/usr/bin/s2.pl %user%"
trig1 -//depot/bar/z* "/usr/bin/s1.pl %user%"
trig1 //depot/bar/zed "/usr/bin/s3.pl %client%"

Both the first and fourth lines call the script /bin/s1.pl %changelist%, since the first occurrence of a particular trigger name determines which script is run when that trigger name is subsequently used.

No triggers are activated if the user submits file //depot/bar/zebra, since the third line excludes this file. But if //depot/bar/zed is submitted, the trig1 script /usr/bin/s1.pl %change% will be run, since the fourth line overrides the third, and because the first script listed with the name trig1 is used.

Related Commands

To obtain information about the changelist being submitted p4 describe
p4 opened
To aid daemon creation p4 review
p4 reviews
p4 counter
p4 counters
p4 user



Perforce Command Reference:   [Index] [Prev] [Next]


Copyright 1999 Perforce Software.
Contact us at [email protected]
Last updated: 09/15/99 (Manual version 99.1.cr.6)