About

Example triggers for Perforce server, starting with one written in C# and P4.Net API
  • 1
    Member
  • 0
    Followers
  • 1
    Branch
Owners
robert_cowham (Robert Cowham)
Members
robert_cowham (Robert Cowham)
Followers
Branches
  • Main

Perforce Example Triggers

This project is to show examples of triggers for Perforce.

P4NetContentTrigger

This is an example of a change-content trigger - with the following features:

  • written in C# (Visual Studio 2010 but should be forwards compatible)
  • uses P4API.NET
  • shows how to turn on logging of all API calls (useful for debugging)
  • has a Python test harness (showing live trigger installation - based on other work)

Usage

Install an entry in triggers table similar to:

ValidateContent submit-content //depot/... "P4NetContentTrigger.exe -p %serverport% -u p4admin -c %changelist%"

The above assumes a user called "p4admin" with appropriate privileges to read the requiredand changelists, and with a login ticket accessible via the environment (so set P4TICKETS in the environment of your service and ensure this user is logged in and part of a Perforce group with Timeout: field set to "unlimited").

Parameters to P4NetContentTrigger.exe:

-p, --port (uses environment if not defined) P4PORT to connect to

-u, --user (uses environment if not defined) P4USER to connect as

-c, --change Required. Changelist to process/validate.

-t, --testing (Default: False) Testing mode - if first line of a file contains 'fail' will return error otherwise success.

-v, --verbose (Default: False) Makes sure log4net logging is set to Debug level. Otherwise edit log4net.properties file.

-h, --help

Packages Referenced

  • CommandLineParser
  • log4net