Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

P4 Server Administration Documentation | 2025.2

# Change-submit triggers

Use the `change-submit` trigger type to create triggers that fire after changelist creation, but before files are transferred to the server. Because change-submit triggers fire before files are transferred to the server, these triggers cannot access file contents. Change-submit triggers are useful for integration with reporting tools or systems that do not require access to file contents.

In addition to the p4 submit command, the `p4 populate` command, which does an implicit submit as part of its branching action, fires a change-submit trigger to allow for validation before submission.

Example:

The following change-submit trigger is an MS-DOS batch file that rejects a changelist if the submitter has not assigned a job to the changelist. This trigger fires only on changelist submission attempts that affect at least one file in the //depot/qa branch.

Copy

    @echo off

    rem REMINDERS
    rem - If necessary, set Perforce environment vars or use config file
    rem - Set PATH or use full paths (C:\PROGRA~1\Perforce\p4.exe)
    rem - Use short pathnames for paths with spaces, or quotes
    rem - For troubleshooting, log output to file, for instance:
    rem - C:\PROGRA~1\Perforce\p4 info >> trigger.log

    if not x%1==x goto doit
    echo Usage is %0[change#]

    :doit
    p4 describe -s %1|findstr "Jobs fixed..." > nul
    if errorlevel 1 echo No jobs found for changelist %1
    p4 describe -s %1|findstr "Jobs fixed..." > nul

To use the trigger, add the following line to your triggers table:

    sample1   change-submit //depot/qa/...   "jobcheck.bat %changelist%"

Every time a changelist is submitted that affects any files under `//depot/qa`, the `jobcheck.bat` file is called. If the string "Jobs fixed…​" (followed by two newlines and a tab character) is detected, the script assumes that a job has been attached to the changelist and permits changelist submission to continue. Otherwise, the submit is rejected.

The second `findstr` command ensures that the final error level of the trigger script is the same as the error level that determines whether to output the error message.

Your search for returned results