Fix-add and fix-delete triggers

Example    

The following script, when copied to fixadd.sh and fixdel.sh, fires when users attempt to add or remove fix records, whether by using the p4 fix command, or by modifying the Jobs field of the forms presented by the p4 change and p4 submit commands.

#!/bin/bash
# fixadd.sh, fixdel.sh - illustrate fix-add and fix-delete triggers

COMMAND=$0
CHANGE=$1
NUMJOBS=$(($# - 1 ))

echo $COMMAND: fired against $CHANGE with $NUMJOBS job arguments.
echo $COMMAND: Arguments were: $*

These fix-add and fix-delete triggers fire whenever users attempt to add (or delete) fix records from changelists. To use the trigger, add the following lines to the trigger table:

sample4   fix-add    fix "fixadd.sh %change% %jobs%"
sample5   fix-delete fix "fixdel.sh %change% %jobs%"

Using both copies of the script, observe that:

  • fixadd.sh is triggered by p4 fix

  • the fixdel.sh script is triggered by p4 fix -d

  • and either script can be triggered by manually adding (or deleting) job numbers from within the Jobs field in a changelist form. This can be done either by means of p4 change or as part of the p4 submit process.

Because the %jobs% variable is expanded to one argument for every job listed on the p4 fix command line (or in the Jobs field of a p4 change or p4 submit form), it must be the last argument supplied to any fix-add or fix-delete trigger script.