Create or display a list of scripts to be run conditionally whenever changelists are submitted, forms are updated, when integrating Perforce with external authentication or archive mechanisms, when rotating journals, or when pushing or fetching content to and from a remote depot.
Perforce triggers are user-written scripts or programs that are called
by a Perforce server whenever certain operations (such as changelist
submission or changes to forms) are performed. If the script returns a
0, the operation continues; if the script returns any other
value, the operation fails.
p4 triggers command includes three variants:
- With no options specified, the command invokes the default editor to allow the user to specify one or more trigger definitions.
-ioption specifies that the user use standard input to specify one or more trigger definitions.
-ooption displays the trigger definitions currently stored in the trigger table.
A trigger definition contains four fields that specify the name of the trigger, the type of event that should trigger the execution of the script, the location of the script, and other trigger type-dependent information. When the condition specified in a trigger definition is satisfied, the associated script or program is executed.
For detailed information about writing triggers and trigger definitions, see "Scripting Perforce: Triggers and Daemons" in the Helix Versioning Engine Administrator Guide: Fundamentals.
Read the trigger table from standard input without invoking the editor.
Write the trigger table to standard output without invoking the editor.
See “Global Options”.
|Can File Arguments Use Revision Specifier?||Can File Arguments Use Revision Range?||Minimal Access Level Required|
Suppose that the trigger table consists of the following entries:
Triggers: trig1 change-submit //depot/dir/... "/usr/bin/s1.pl %changelist%" trig2 change-submit //depot/dir/file "/usr/bin/s2.pl %user%" trig1 change-submit -//depot/dir/z* "/usr/bin/s1.pl %user%" trig1 change-submit //depot/dir/zed "/usr/bin/s3.pl %client%"
Note the indentation; the
Triggers: field name is not indented; each
row is indented with at least one space or tab character.
Both the first and third lines call the script
%changelist%, because the first occurrence of a particular trigger name
determines which script is run when the trigger name is subsequently
No triggers are activated if someone submits file
because the third line excludes this file. If someone submits
%changelist% is run: although the fourth line overrides the third,
only the first script associated with the name
trig1 is called.
For more detailed examples, see "Using triggers to customize behavior" in Helix Versioning Engine Administrator Guide: Fundamentals.