Review Board supports posting and reviewing code on Perforce repositories.
Perforce is widely used by large software and hardware companies. Unlike many source code management products in this space, Perforce keeps track of all changes that are in progress, including their pending change descriptions. Review Board makes use of this information to help post changesets for review and to indicate when a changeset has been submitted to the repository.
Review Board supports username/password authentication or ticket-based authentication for Perforce, and also supports connecting using SSL or Stunnel.
This guide assumes that you’re adding a Perforce repository that’s hosted somewhere in your network or one that’s accessible by your Review Board server. Review Board requires local or network access to your repository.
Follow the documentation in the links below if your Perforce repository is hosted on one of these services, as configuration may differ.
Installing Perforce Support¶
Before you add the repository, you will need to install the following:
The p4 command line tool.
This must be placed in your web server’s system path, and must be executable by the web server.
The p4python bindings.
This can be installed by running:
$ pip3 install -U 'ReviewBoard[p4]'
You will then need to restart your web server for the new module to be noticed by Review Board.
Adding the Repository¶
To configure a Perforce repository:
Add a new repository and select Perforce from the Repository type field.
Set the Path field to the Perforce server.
Configure a Perforce standard user account for repository configuration.
Save the repository.
If using SSL, this may ask you to verify the certificate.
If you have any trouble configuring the repository, you can reach out to us for support.
Determining your Repository Path¶
To determine the repository path to use, run the following inside a checkout of your repository:
$ p4 info
Server address field contains the value to use for the repository
path in Review Board.
Modern versions of Perforce (2012.1 or higher) natively support SSL connections.
If your Perforce server listens over a SSL connection, you can connect by
ssl: to the path. For example:
Follow Perforce’s guide on enabling SSL support to get started.
If you’re not using a SSL-backed connection, and your Perforce server is located in a different network, you may want to set up a Stunnel connection. This will provide an encrypted connection between Review Board and your Perforce server, and can be used for any version of Perforce.
To use Stunnel:
Follow Perforce’s guide on using Stunnel. This will take care of the configuration on the Perforce server.
Install Stunnel 3 or higher on the Review Board server.
The stunnel binary must be in the web server’s path.
Configure your repository path to point to your Stunnel proxy.
To do this, prefix your standard repository path with
stunnel:and list the port that the Stunnel server is running on. Review Board will take care of the rest.
For example, if Stunnel is listening on port 2666, you can use:
Review Board will automatically set up a local tunnel client as necessary. It will bind this to a port between 30000 and 60000 on localhost, and proxy all requests through it.
Choosing a Perforce User¶
Review Board communicates with your Perforce repositories using a single Perforce user.
This user must meet the following criteria:
The user must be a Perforce standard user.
Perforce service users and Perforce operator users are not supported. Both are restricted to a subset of Perforce commands used for Perforce management tasks. The commands required by Review Board to access the contents of files in depots are not available to these users.
Granting a service user or operator user the “super” permission does not change this.
See the p4 user documentation for the differences between types of users.
The user must have read access to all depots used on Review Board.
This is required in order for Review Board to fetch file contents and generate diffs.
If the user does not have access to a given depot, people will not be able to post changes on that depot for review.
It must be allowed to invoke the following commands:
You can either create a dedicated user for Review Board, or you can use an existing user that meets all the necessary criteria.
Using Ticket-Based Authentication¶
Review Board supports using ticket-based authentication for Perforce. To enable this:
Provide the credentials for the Perforce user, as normal.
Enable Use ticket-based authentication in the Review Board repository configuration.
Review Board will handle storing the ticket information and requesting new tickets when necessary. You don’t have to do anything else.
Installing the Trigger Script¶
We provide a trigger script for your Perforce server, which does the following:
Checks that submitted changes are put up for review and approved, blocking them if they fail these checks.
Automatically closes review requests once changes are submitted.
We recommend this for all Perforce users.
To install the trigger script:
Install RBTools and the Perforce command line tools on the Perforce server.
Make sure that rbt and p4 are in the system path used by the Perforce server.
Download the trigger script and place it where the Perforce server can run it.
Set the options in the downloaded trigger script to match your environment.
There are instructions within the file for each option. These will be entirely dependent on your setup.
You can also choose which checks to activate and which actions to perform.
Run p4 triggers and add the trigger script:
reviewboard change-submit //depot/... "/path/to/python /path/to/p4-trigger-script %changelist%"
Customize the Python executable path, depot path, and the path to the trigger script above.
Make sure your Python executable path is the same environment in which RBTools was installed.
If you’re installing on Windows and using the RBTools for Windows installer, your Python path should be:
You should now be up and running!
If you have any trouble configuring the trigger script, you can reach out to us for support.
Posting Changes for Review¶
To post changes for review, you will need to use RBTools. Standard Perforce diffs leave out a lot of important information necessary to properly identify files, which RBTools works around.
See Using RBTools with Perforce for more information.