Workflow global rules
Configure a workflow to control how P4 Code Review processes changelists, reviews, and automated decision logic.
P4 Code Review comes with a global workflow already present. You can only have one global workflow within P4 Code Review.
Workflow prerequisites
The workflow feature is enabled by default for P4 Code Review 2019.2 and later
Workflows require
-
Workflow enabled in the workflow section of
SWARM_ROOT/data/config.php. -
A correctly configured swarm-trigger.conf file.
-
If you are using triggers, ensure the workflow lines are present in the within the trigger table. For more information, see Installing triggers.
To disable workflows, edit the following section of the config.php file.
'workflow' => array(
'enabled' => false, // Switches the workflow feature on. Default is true
),
The default value is true.
Disabling workflow stops P4 Code Review processing workflow rules, but P4 Server still incurs minimal overhead unless workflow-related triggers are commented out.
Global workflow
Global workflow rules allow administrators to enforce organization‑wide workflow behavior.
Each rule can be set to Enforce off (default) or Enforce on, which determines how the rule interacts with project‑level workflows.
Enforce off (default)
-
The rule applies only to projects or project branches without an associated workflow.
-
If a project or branch has its own workflow, the global rule is ignored.
Enforce on
-
The rule becomes a minimum workflow requirement for all projects and branches.
-
If a project or branch has its own workflow, P4 Code Review merges the global rule with the project rule, using the most restrictive setting.
Editing the Global Workflow
Only admin or super users have permission to modify the global workflow. Configuration changes take effect after the P4 Code Review configuration cache is reloaded. 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 System Information.
To edit the global workflow:
-
Click Workflows in the left navigation panel.
-
Click Global Workflow to open the settings page.
-
In the General Settings tab, update the Name and Description fields.
-
In the Global Rules tab, determine which workflow rules to enforce. Each rule has an Enforce slider to control how the rule is applied across the system:
-
Enforce off:-
Applies the rule to projects and branches that do not have an associated workflow.
-
If a project or project branch is assigned a workflow, the global rule is ignored.
-
-
Enforce on:-
Applies the rule as a minimum requirement to all projects and branches.
-
If a project has its own workflow, P4 Code Review merges the settings and uses the most restrictive value. For an example, see Merging multiple workflows.
-
Changes affect all projects and branches.
-
For more information on how to configure the rules, see Add a workflow.
-
-
With the Global Rules tab is a table for Members or groups who can ignore ALL workflow rules.
This table allows you to manage the users and groups that over-ride the rules set by the workflow, including the global workflow. These permissions are normally restricted to a small, trusted set of users or groups, typically project owners or administrators.
-
In the Project tab, view the projects and project branches that the workflow has been applied to.
-
In the Tests tab, add tests to a workflow to validate reviews at key points in the review lifecycle. You can only add existing tests to a workflow. For more information on creating tests, see Add a test.
Tests run when a review associated with the workflow is created, updated, or submitted, depending on the selected trigger condition. For more information, see Configure tests for global workflow.
-
In the Owners tab, update the Owners of the global workflow. To add an Owner, click Add Owner and choose the user or group to assign as the workflow owner.
When updating the workflow owners, consider the following:
-
The Global Workflow must have at least one owner.
-
If you remove yourself as an owner, you cannot later edit the workflow unless you have super user rights.
-
-
To return to the workflow home page, Workflows in the left navigation panel.
Configure tests for global workflow
Tests can be added to a workflow to validate reviews at key points in the review lifecycle.
Tests run when a review associated with the workflow is created, updated, or submitted, depending on the selected trigger condition.
If a review is associated with multiple workflows, all tests from all workflows run. When the same test appears in multiple workflows, it runs only once.
Adding a Test
Within the Tests panel of the workflow configuration page:
-
Click + Add Test. This activates several fields to configure for the test.
-
Select a test from the Tests dropdown.
-
Choose when the test should run from the When dropdown. Chose from the following:
-
On Update: The test runs when:
-
A review is created.
-
A review is submitted and its content has changed compared to the previous version.
-
A review is updated and its content has changed since the previous version.
If review content has not changed since the last successful test pass, the test is not re-run on updates or submits.
If the test is currently running, or if it has not yet reported a pass state, it will be re-run, including during submit.
-
-
On Submit: The test runs when either:
-
A pre‑commit review is submitted.
-
A post‑commit review is created.
-
-
On Demand:
-
The test does not run automatically.
-
It can be triggered manually from the Tests dialog on the review page.
-
This option is independent of the “review content change” requirement.
-
-
-
Select approval‑blocking behavior from the Blocks dropdown. Chose from one of the following options:
-
Nothing - A test failure does not block review approval.
-
Approve - A test failure prevents the review from being approved.
-
Removing a Test
-
Click the Delete button next to the test you want to remove.
-
The test is removed immediately - no confirmation prompt is shown.