P4 Code Review configuration

Now that P4 Code Review is ready for use, you need to configure it to work in your environment.

P4 Code Review does not support P4 Servers configured to use P4AUTH, see Centralized authorization server (P4AUTH) in the P4 Server Administration Documentation.

  • P4 Code Review can be connected to P4 Servers (P4D) and commit servers.
  • To configure P4 Code Review to connect to more than one P4 Server (P4D), see Multiple P4 Server instances.

    To configure P4 Code Review to connect to a P4 Server configured to use commit-edge architecture, see Commit-edge deployment.

  • P4 Code Review must not be connected to P4 Broker, P4 Proxy, P4 Edge, forwarding replica, or read-only replica servers.

Swarm configuration file

  • If your P4 Server is configured for P4 AS, the P4 Server must be temporarily configured to allow fall-back to passwords while you establish a connection to the P4 Server. Run the following command on the P4 Server to enable fall-back to passwords:

    p4 configure set auth.sso.allow.passwd=1

Edit the SWARM_ROOT/data/config.php file so that it contains the following configuration block:

<?php
    return array(
        'p4' => array(
            'port'      => 'my-helix-core-server:1666',
            'user'      => 'admin_userid',
            'password'  => 'admin user ticket or password',
            'sso'       => 'disabled', // 'disabled'|'optional'|'enabled'
                                       // default value is 'disabled' 
         ),
         'log' => array(
             'priority'  => 3, // 7 for max, defaults to 3
         ),
         'mail' => array(
             'transport' => array(
                 'host' => 'my.mx.host',
             ),
         ),
    );

port

For the port value, replace my-helix-core-server:1666 with the P4PORT value used to connect to your P4 Server.

If your P4 Server is deployed using the commit-edge architecture, ensure that Swarm's port value points to the commit server.

For more information, see Commit-edge in the P4 Server Administration Documentation.

If the port points to a P4 Broker, ensure that the broker does not delegate commands to different replicas, edge servers, or proxies. Such delegation can cause odd problems or outright failures in Swarm.

Swarm needs to have a consistent, current view of the state of P4 Server, and works best when it connects to a central/commit server.

user

For the user value, replace admin_userid with a normal P4 Server userid that has admin-level access to P4 Server.

  • This user is used by P4 Code Review to communicate with the P4 Server. It should not be used to perform everyday P4 Code Review reviewing tasks.
  • P4 Server 2020.1 and later, permissions have changed for viewing and editing stream spec files in P4 Code Review. To view and edit stream spec files in P4 Code Review, the P4 Code Review user must have admin permissions for the entire depot //...

password

For the password value, while a plain-text password works, we recommend that you use a ticket value instead. Obtain the ticket value for the admin_userid during login with this command:

p4 -p my-helix-core-server:1666 -u admin_userid login -p

  • If your P4 Server authentication is configured in the one of the following ways, ticket-based authentication is required:

    • Authentication configured with security level 3.

    • Authentication configured for LDAP.

    • Authentication configured for P4 AS.

  • You must use a long-lived login ticket for the P4 Code Review user.

You can determine when the admin userid ticket will expire with:

p4 -p my-helix-core-server:1666 -u admin_userid -P ticket_value login -s

For more information about tickets, see the section Ticket-based authentication in the P4 Server Administration Documentation.

sso

P4 Code Review can be configured for the P4 AS when the P4 Server is also configured for the P4 AS.

Set sso to one of the following:

  • enabled all users must use P4 AS to log in to P4 Code Review.

    The login page displays an input box to enter the email or username. Once the input box is filled, the Log in with SSO button is activated. See Log in with SSO.

    If SAML is configured when the sso configurable is enabled, the user can only log in to Swarm using the Log in with SSO button.

  • optional P4 AS is available for users to log in to P4 Code Review but is not enforced.

    The login page displays an input box to enter the email or username. Once the input box is filled, the Log in with SSO button is enabled. To log in with SSO, see Log in with SSO.

    The user can also manually log in to P4 Code Review using the Log in with credentials button. To log in manually, see Log in with a password.

    If you switch to Log in with credentials and then decide to use single sign-on, click Log in with SSO.

    If SAML is configured when the sso configurable is set to optional, the user can either log in to Swarm using the Log in with SSO button or the Log in with credentials button.

  • disabled P4 AS is not available to P4 Code Review. This is the default value.

    The login page displays two input boxes to enter the email or username, and to enter the password. Once the input boxes are filled, the Log in with credentials button is activated. See Log in with a password.

From P4 Code Review 2021.1, the sso_enabled configurable is deprecated but remains supported. It is replaced with the more flexible sso configurable. If the sso_enabled configurable and sso configurable are both present in the p4 configuration block, P4 Code Review uses the sso configurable value.

host

For the host value, replace my.mx.host with the hostname of the mail exchange service that P4 Code Review should use to send its email notifications.

Since this configuration file contains the credentials for a P4 Server admin-level user, we recommend that this file's ownership and permissions be adjusted such that only the web server user can read the file, and that no user can write the file.

Next step

Configure the P4 Server to notify P4 Code Review about P4 Server events, see Configuring P4 Server event notification.