Add a workflow

To ensure you have a workflow appropriate for your organization's needs, you can add workflows. To learn what workflows are and how they can apply to your projects, see Workflow overview as well as Example workflows.

Add a Workflow

  1. In the P4 Code Review navigation pane, click Workflows.

  2. In the top right corner of the Workflows page, click + Add Workflow.

  3. In the Add Workflow window, in Name, enter a unique name for the workflow and click Create.

  4. You are navigated to the Workflow page, where you can configure the workflow using the following five tabs.

    • General Settings

    • Rules

    • Projects

    • Tests

    • Owners

    The settings are auto-saved as they are updated.

  5. In General Settings, configure the following:

    • Name: Enter a unique name for the workflow.
    • Description: (Optional) Add a description for the workflow.
  6. In Rules, configure the rules to define how P4 Code Review handles changelists and reviews during the review process. These rules determine the level of control, automation, and enforcement applied to a project or branch. For more information on how to configure each of the rules, see Workflow rules. Below is a summary of what the rules do:

    • On commit without a review : Defines what happens when a changelist is submitted without an associated review.

    • On commit with a review: Determines whether a changelist linked to a review can be submitted without approval.

    • On update of a review in an end state: Controls whether changelists can be automatically added to reviews in protected end states.

    • Count votes up from: Specifies the users who have votes count that toward approval requirements.

    • Automatically approve reviews: Determines whether reviews are approved automatically when all approval criteria are met.

    For examples of what these rules can do, see Example workflows.

  7. In Projects, view the projects and branches the workflow has been assigned to. If you are creating a new workflow, this page will be empty. For more information, see Add a workflow to a project or a branch.

  8. In Tests, add a test to a workflow. A test is an automated check linked to a workflow. A test is run when a review is created, updated, or submitted. Workflow tests can integrate with external systems such as CI pipelines or test suites.

    You must create a test before it can be added to a workflow. For more information on how to create a test, see Add a test.

    To add a test:

    1. Click + Add Test. This activates several fields to configure for the test.

    2. Select a test from the Tests dropdown.

    3. 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.

    4. 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.

  9. In Owners, add an owner to the workflow. By default, you are assigned as the owner of the workflow. You can add up a total of 20 individuals or groups.

    To add an owner:

    1. Click + Add Owner.

    2. In the Add Owners, window chose to add:

      • Users - Add an individual user as a workflow owner.

      • Groups- Add a user group as a workflow owner. Every user within that group is then assigned as the owner of the workflow and can edit or delete it.

    3. In both cases, select the user or group from the drop down field and click Add.

    4. To remove a user or group as a workflow owner, click the delete icon next to the user or group.

      If you remove yourself as the owner, you cannot edit this workflow, unless you have super user rights.

    5. Shared with others: (Optional) Select to allow other P4 Code Review users to be able to use this workflow. For more information on shared workflows, see Sharing workflows with others.

  10. The workflow configuration is auto-saved as you updated it. To return to the workflow homepage, click Workflows in the left navigation pane.

The workflow is now live and can be applied to projects and branches. Apply a workflow to a project within the General Settings section of the Project settings page. For more information, see Project settings

Workflow rules

Learn how to configure workflow rules.

On commit without a review

This rule applies when a changelist without an associated review is submitted outside of P4 Code Review.

Options:

  • Allow: (Default) The changelist is submitted normally. No review is required.

  • Create a review: The changelist is submitted, and a review is automatically created for it.

  • Reject: The submit is rejected because no review is associated with the changelist.

The selected rule is also applied when a changelist is submitted with #review in the description. For more information about creating a review by including a keyword in the changelist description, see Create a review.

On commit with a review

This rule applies in the following cases:

  • A review is committed.

  • A changelist that already has an associated review is submitted outside of P4 Code Review.

Options:

  • Allow: (Default) The review state is not checked. The changelist is submitted even if its associated review is not approved.

  • Reject unless approved: The changelist is submitted only if:

    • Its associated review is approved.

    • The changelist content matches the approved review’s content.

Additional behavior

This rule also applies when the changelist description contains:

  • #review-nnnnn

  • #replace-nnnnn

  • #append-nnnnn

(Where nnnnn is a review ID)

For more information on these keywords, see Add a changelist to a review.

On update of a review in an end state

This rule controls whether review content can be automatically updated when a review is in a protected end state.

By default, protected end states include:

  • Archived

  • Rejected

  • Approve:Commit

The P4 Code Review administrator can redefine which states are considered end states. A review in an end state can still be manually updated from the P4 Code Review platform. This rule is triggered when a changelist is added to a review.

Options:

  • Allow: (Default) The review state is not checked; the changelist is added regardless of the review’s state.

  • Reject: If the review is in one of the end states defined in end_state:

    • The Add Change button is disabled.

    • The changelist is rejected if added outside P4 Code Review using any of:

      • #review-nnnnn

      • #replace-nnnnn

      • #append-nnnnn

Count votes up from

By default, all up votes on a review contribute to the Minimum up votes required by the associated project or branch.

This rule allows restricting which reviewers’ votes count toward that requirement. This rule applies when a user votes on a review.

Options:

  • Anyone: (Default) Up votes from all reviewers count toward the minimum.
  • Members: Only up votes from project members count toward the minimum for that project or branch..

For instructions on how to set Minimum up votes for projects and branches, see Project minimum up votes and Branch minimum up votes.

Automatically approve reviews

By default, reviews must be approved manually. This rule enables automatic approval when vote requirements are met.

This rule applies when a user votes on a review.

Options:

  • Never: (Default) Reviews are not automatically approved.

  • Based on vote count: A review is automatically approved if all of the following are true:

    • No down votes exist.

    • The review has no moderators. Moderators prevent automatic approval. For more information, see Moderators.

    • All Required reviewers have up‑voted.

    • The Minimum up votes requirement is met for each project and branch the review spans.

    • All approval‑blocking tests have passed.

After automatic approval, the review must still be committed manually.

Sharing workflows with others

P4 Code Review workflows can be created by any P4 Code Review user.

Selecting Shared with others allows other P4 Code Review users to view that workflow. Shared P4 Code Review workflows can be applied to a project or project branch by any user that is authorized to edit the project.

Leave the Share with others option unselected to keep the workflow private until you have verified the workflow is ready to share with others.

If Shared with others is not selected for a workflow, only the owners of the workflow can apply the workflow to a project.

The global workflow can be viewed by any P4 Code Review user. However, only a user with super or admin privileges can edit the global workflow unless that user has been assigned as an owner.