Comment attachments
P4 Code Review supports attaching arbitrary files to comments in code reviews and jobs.
If you make a configuration change, P4 Code Review will not use it until the configuration cache has been reloaded, this forces P4 Code Review to use the new configuration. You must be an admin or super user to reload the P4 Code Review config cache. Navigate to the User id dropdown menu, select System Information, click the Cache Info tab, and click the Reload Configuration button.
Comment attachment storage
To store files attached to comments, P4 Code Review looks for a depot named //.swarm
. As P4 Code Review does not create this depot, you need to create it, or specify another depot that the P4 Code Review admin user can write to.
The depot used to store P4 Code Review attachments must be:
- a classic depot (stream, unload, archive, and spec depots are not supported)
- a local depot (remote depots are not supported)
- a depot that the P4 Code Review admin user can write to but other users cannot access. For more information about permissions, see Authorizing access in the P4 Server Administration Documentation.
It is best practice to use a depot directory that is not used to store any other files, this stops other users having access to the attachments stored in the depot. We recommend that you use //.swarm
Create a directory for the comment attachments
We recommend that you use //.swarm because it is best practice to use a depot directory that is not used to store any other files This prevents other users from having direct access to the comment attachments.
- To create a
//.swarm
depot, run the following as a user with admin-level privileges: - Ensure that the P4 Code Review admin user can write to the
//.swarm
depot and make sure that other users cannot access it.
$ p4 depot .swarm
For information on creating depots, see Working with depots in P4 Server Administration Documentation.
Specify the location for the comment attachments
By default P4 Code Review looks for a depot named //.swarm, to specify a different depot path for comment attachments, use the depot_storage configuration block in the SWARM_ROOT/data/config.php
file.
It is mandatory to include the depot_storage configuration block in the P4 Code Review configuration. Failure to include the depot_storage configuration block will result in the option to add an attachment to a comment being unavailable in the P4 Code Review UI.
Replace depot_name
with the depot where comment attachments are stored. The P4 Code Review admin needs to be able to write to this depot but make sure that other users cannot access it:
<?php
// this block should be a peer of 'p4'
'depot_storage' => array(
'base_path' => '//depot_name',
),
The base_path can be more than just the depot name, for example //depot/perforce/.swarm would work.
Maximum comment attachment size
By default, the maximum file size of a single comment attachment is limited to:
-
Ubuntu: 8Mb
-
RHEL 8 and later: 2Mb
Increasing the maximum attachment file size
Your can increase the maximum attachment size if required.
Ubuntu
Edit the php_value upload_max_filesize and php_value post_max_size configurables in the .htaccess file.
RHEL 8 and later
Edit the upload_max_filesize and post_max_size configurables in the /etc/php.ini file.