Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

P4 for Jenkins Documentation | 1.17.3

# Quick start

This quick start shows how to install P4 for Jenkins plugin, connect to the P4 Server and run a simple job that syncs files from Perforce.

## Before you begin

Ensure you have the following:

- Jenkins is installed and running.

- Access to a working version of P4 Server.

- The server and port values for P4 Server.

- The username and password of your P4 user.

- Access to a Perforce depot or stream.

- (Optional) P4V, to view depots, streams, and submitted changelists.

## Install the P4 for Jenkins plugin

The easiest way to install the P4 for Jenkins is through the Jenkins UI.

1. In Jenkins, select Manage Jenkins.

2. In System Configuration, select Plugins.

3. Select the Available plugins tab.

4. Search for P4.

5. Install P4 Plugin.

6. Restart Jenkins if prompted.

P4 for Jenkins is now installed. To learn more about other P4 for Jenkins installation methods, see Installation.

## Add Perforce Credentials

Jenkins uses credentials to authenticate to the P4 Server.

1. In Jenkins, select Manage Jenkins.

2. In Security, select Credentials.

3. Click Add Credentials.

4. In the Add Credentials window, select Perforce Password Credential and click Next.

5. Provide the following information:

   - Scope: Select Global.

   - ID: Enter an easy to find identifier, for example, `p4-credentials`.

   - Description: Enter a simple description, such as, Perforce credentials for Jenkins.

   - P4PORT: The port number for your P4 Server. For example, `localhost:1666`.

   - Username: Your Perforce username.

   - Password: Your Perforce user password.

6. Click Test Connection to validate the credentials.

7. Click Create.

Jenkins now knows how to authenticate to Perforce.

## Create a Job

This job will sync files from Perforce and verifies that the connection works.

Jenkins creates and manages its own Perforce workspace for the job. You do not need to create a workspace manually within P4V.

1. From the Jenkins dashboard, select New Item.

2. Enter a name (for example, `P4Test`)

3. Select Freestyle project and click OK.

   There are lots of fields on the following configuration page, most of which can be left empty or with just the default values selected.

4. In Source Code Management, select Perforce Software.

5. Configure the following:

   - Perforce Credentials: Select the credentials you created earlier.

   - Workspace behaviour: Select Manual.

   - Workspace name: Enter a unique name for the workspace. A warning message will appear saying "Unknown Client" - this is expected as the workspace does not exist yet.

   - Steam: Enter the P4 Server depot path for the stream that will be used to create Jenkins build workspace. If you are connected to a P4 Server, the depot name auto populates as you type. For example, enter: `//DemoDepot/main`.

6. Click Save.

7. You are navigated to the job page for the job you just created. To check the connection between P4 for Jenkins and P4 Server, click Build Now.

8. After the build completes, click the build number.

9. (Optional) If you have P4V, you will see a new workspace.

10. In Summary of Changes, click View Details.

If the connection is successful, you will see a list of files in the depot within the Jenkins UI.

## Next steps

### Add build, test, or packaging steps to the job.

After Jenkins successfully syncs files from Perforce, you can add build, test, or packaging steps (for example, shell commands, batch files, or build tools) to your job. To learn more, see:

- Building jobs

- Freestyle job setup

### Configure polling or webhooks to trigger builds automatically

Instead of running jobs manually, you can configure Jenkins to trigger builds when changes are submitted to Perforce. To learn more, see Perforce triggered build.

### Explore advanced workflows, such as submitting results back to Perforce

Advanced workflows allow Jenkins to perform additional Perforce operations, such as labeling builds, unshelving files, or submitting generated content back to Perforce. These workflows are typically used in automated pipelines and advanced CI systems.

To learn more, see:

- Building jobs

- Workflow setup guide

Your search for returned results