Perforce 2002.1 Command Reference
<< Previous Chapter
p4 sync
Table of Contents
Index
Perforce on the Web
Next Chapter >>
p4 typemap

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. Upon failure, the script's standard output (not error output) is used as the text of the failed command's error message.

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 holds three values:

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 accessible from 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 the Global Options section.

Usage Notes

Can File Arguments Use
Revision Specifier?

Can File Arguments Use
Revision Range?

Minimal Access Level Required

N/A

N/A

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 2002.1 Command Reference
<< Previous Chapter
p4 sync
Table of Contents
Index
Perforce on the Web
Next Chapter >>
p4 typemap
Please send comments and questions about this manual to [email protected].
Copyright 1999-2002 Perforce Software. All rights reserved.
Last updated: 04/03/02