Additional triggers for push and fetch commands
The section
Triggering on pushes and fetches
describes the triggers that you can run during the various phases of the
p4 push
and p4 fetch
commands.
These are command
triggers that are run by the server initiating the push or the
fetch. However, for every initiator, there is a responder:
- For every push by server A to server B, there is a server B receiving the items pushed by A.
- For every fetch by server A from server B, there is a sever B that is being fetched from.
This creates additional trigger opportunities for the server receiving
the push and the server responding to the fetch request. You can use
command
type triggers to take advantage of these
opportunities. Within this context:
pre-user
andpost-user
actions refer to the server initiating the push or fetch.pre-rmt
andpost-rmt
actions refer to the responding server.
The responding (or remote -rmt-
) server can use these triggers:
Trigger | Run this trigger on the remote server |
---|---|
|
Before it receives pushed content |
|
After it receives pushed content. Two special variables are available for use with post remote push triggers:
|
|
before it responds to a fetch request |
|
After it responds to a fetch request |
The following table describes the fields for the trigger definition.
Field | Meaning |
---|---|
|
The name of the command trigger. |
|
|
|
The The
Examples of possible values:
|
|
The trigger for Helix Core Server
to run when the condition implied by Specify the command in a way that allows Helix Core Server
to locate and run the command. The When your trigger script is stored in the depot, its path must
be specified in depot syntax, delimited by percent characters.
For example, if your script is stored in the depot as
|
Examples
Example pre-rmt-Fetch command trigger
#!/bin/bash # pre-rmt-Fetch trigger example # Trigger table entry: # prerfetch command pre-rmt-Fetch "pre-rmt-fetch.sh %serverid% %peerhost%" serverid=$1 peerhost=$2 echo -e "Remote $peerhost is initiating a fetch of data from $serverid\n" | mail -s "Data is being fetched from $serverid to $peerhost" perforce-admin@localhost exit 0
Trigger table entry
prerfetch command pre-rmt-Fetch "pre-rmt-fetch.sh %serverid% %peerhost%"
Example post-rmt-Fetch command trigger
#!/bin/bash # post-rmt-Fetch trigger example # Trigger table entry: # postrfetch command post-rmt-Fetch "post-rmt-fetch.sh %serverid% %peerhost%" serverid=$1 peerhost=$2 echo -e "Remote $peerhost has been fetching data from server $serverid\n" | mail -s "Data has been fetched by $peerhost from server $serverid" perforce-admin@localhost exit 0
Trigger table entry
postrfetch command post-rmt-Fetch "post-rmt-fetch.sh %serverid% %peerhost%"
Example pre-rmt-Push command trigger:
#!/bin/bash # pre-rmt-Push trigger example # Trigger table entry: # prerpush command pre-rmt-Push "pre-rmt-push.sh %serverid% %peerhost%" serverid=$1 peerhost=$2 echo -e "Remote server $peerhost is initiating a push of data to server $serverid\n" | mail -s "Data being pushed to server $serverid from $peerhost" perforce-admin@localhost exit 0
Trigger table entry
prerpush command pre-rmt-Push "pre-rmt-push.sh %serverid% %peerhost%"
Example post-rmt-Push command trigger
#!/bin/bash # post-rmt-Push trigger example # Trigger table entry: # postrpush command post-rmt-Push "post-rmt-push.sh %firstPushedChange% %lastPushedChange% %serverid% %peerhost%" firstchange=$1 lastchange=$2 serverid=$3 peerhost=$4 if [ $firstchange = 'unset' ]; then echo -e "Remote server $peerhost attempted a push of data but there was nothing to push\n" | mail -s "Nothing to push from $peerhost" perforce-admin@localhost else echo -e "Remote server $peerhost has pushed data to $serverid,\nFirst change $firstchange, last change $lastchange" | mail -s "Data pushed to $serverid from $peerhost" perforce-admin@localhost fi exit 0
Trigger table entry
postrpush command post-rmt-Push "post-rmt-push.sh %firstPushedChange% %lastPushedChange% %serverid% %peerhost%"