We use Perforce at work, and routinely keep software projects in the repository. In general creators follow the normal Perforce flow, BUT we also have a class of users, who doesn't have any need to edit the files but only read them. Currently we use P4Web but that requires the user so download each file individually to reassemble the project directory. Ideally I would like to have a process where when a user does a commit/submit in Perforce, the script would automatically run to generate a single zip file of the project directory and files, so that it was a one-click download that was guaranteed to be correct against current state of the source files. I know Git has a post-commit hook which could be used for this, but I can't figure out an equivalent function in Perforce.
Short answer: Yes, read the documentation, page 103.
Here is a link to all of the documentation available from Perforce.
Long answer, you can edit the triggers by typing p4 triggers
from the command line. You provide the name of the trigger (i.e. "my_archive"), the type of trigger (i.e. change-commit in your case), path (i.e. the //depot/path/to/the/directory/that/contains/the/files/to/zip/...), and the command_path (your script), plus any variables to pass along to your script.
Really, take a look at the docs, it is really quite simple and powerful.
If they just need read access, then just give them read access in the p4protect table. That way you avoid having to mess around with snapshots of your repository.
来源:https://stackoverflow.com/questions/1743717/can-a-script-be-automated-after-a-commit-on-perforce