Automatically deploy code within a review

The project level test and deploy code features will be deprecated in a later P4 Code Review release. We recommend you use test integration to automatically deploy code within a review. For more information, see Add a test.

Overview

Deploying code in a code review automatically involves enabling Automated Deployment in your project's configuration and providing a trigger URL. When the trigger URL is requested, P4 Code Review expects a deployment program to be executed.

When the deployment processing ends, P4 Code Review expects either a success callback URL or failure callback URL to be requested by your deployment program. These callback URLs should include a url parameter (either via GET or POST).

When a valid-looking URL is included, clicking the deployment status indicator directs the user to the specified URL. This is intended to facilitate easy viewing of the successfully deployed review, or a report indicating why the deployment failed.

The url parameter is mandatory for successful deployments, but is optional for failures.

Prerequisite

Ensure that the build server has a Diffie-Hellman(DH) key size of 2048 bits or greater. Otherwise, the OpenSSL security policy embedded in the operating system rejects the attempt of a TLS handshake with this message:

error:0A00018A:SSL routines::dh key too small

Steps

  1. Navigate to the project page.
  2. Click the project Settings tab to display the Project Settings page.
  3. Automated Deployment checkbox: select Enable to display the configuration field:
  4. Automated Deployment configuration fields image

  5. Provide a URL that triggers your deployment execution.

    Special arguments are available to inform your deployment program of various details from P4 Code Review:

    P4 for Jenkins 1.10.11 and later: P4 Code Review must send the parameters for the build to Jenkins as a POST request. To do this, enter the parameters in the Post Body and select URL Encoded.

    {change}
    The change number
    {status}
    Status of the change, shelved or submitted
    {review}
    The review's identifier
    {project}
    The project's identifier
    {projectName}
    The project's name
    {branch}
    The branch identifier(s), comma-separated
    {branchName}
    The branch name(s), comma-separated
    {success}
    Deployment successful callback URL
    {fail}
    Deployment failure callback URL