Summary

Integrates Jenkins with Perforce SCM Repositories.


{jenkins-plugin-info:pluginId=perforce|jiraComponent=perforce-plugin}
This plugin is very old and not very well maintained anymore. It's recommended that you use the official plugin from Perforce instead: P4 Plugin

With this plugin you can use a workspace (aka Clientspec in Perforce speak) that will synchronize files to the Jenkins workspace. At the moment, this plugin supports:

If polling is enabled, the plugin will automatically sync to the latest revision when new changelists are found. This will also trigger a new build. Also, whenever a new build is triggered manually in Jenkins, the plugin will sync to the latest revision in the Perforce depot.

Requirements

The plugin requires that the command line client p4 is installed on the machine running Jenkins.

Usage

  1. Allow the plugin to communicate with Perforce...
    1. Either create a new user or use an existing "daemon" type user
      • Note: This "daemon" user must be logged in prior to configuring or running builds with Jenkins. And you must not specify the P4CLIENT environment variable because this will overwrite anything that Jenkins is trying to do.
    2. Create a workspace (clientspec) for the plugin to use. Name it "jenkins-jobname" or something.
    3. Ensure that the workspace matches your development settings for your project (e.g., LineEnd, Options, etc.)
    4. Important Note: If you will be concurrently building multiple projects from Perforce, it would be best to create a Perforce workspace for each project.
  2. Install the plugin. Download it here.
  3. Create a new project, under "Source Code Management," choose Perforce.
  4. Enter your server specific details along with the information for the user that Jenkins will be using for polling/syncing. If you are familiar with Perforce, this all should be second nature. Remember, click on the question mark icons for context sensitive help.
  5. Under Build Triggers, check "Poll SCM."
  6. Save your changes and let Jenkins do its job.

Post Configuration

A new option will appear on your project's details page: "Perforce Polling Log." You can check this to see what Perforce has been up to...

Within any build for your project, a new option appears: "Label This Build." Click on this to see the following screen. Here you can create a Perforce Label allowing your team to sync to this build.

Quirks

Advanced Configuration

Sync multiple builds to the same changeset


Say you have a stream of builds that need to run and you need every build to sync to the same changeset. There are a couple of ways to accomplish this. The first is to use a counter. In your job configuration for Job A, you will need to define a P4 Counter (say "projectA-counter") and check "Update counter to most recent changeset". Assuming your perforce user has sufficient privileges to create and set counters, this will check out Job A with the latest changeset, and update the counter with that changeset number. Then you can configure the rest of the jobs to use the counter "projectA-counter" and they will automatically sync to that changeset.

The alternative way is to pass the changeset through the builds as a parameter using the parameterized trigger plugin. In order to do this, you will need to dump the changeset number from the build environment into a properties file so the trigger can read it. A build step with

echo p4.changelist=$P4_CHANGELIST > change.properties

will create the properties file that can be loaded with the parameterized trigger plugin. After that it's just a matter of adding the 'p4.changelist' parameter to the downstream job, and using it in the "P4 Label" configuration field of the perforce plugin.

Note that with both these techniques, the changelog information for the downstream builds will not be available.

Other notes

Version 1.3.8 "Create Workspace" breakage


In version 1.3.8 a new option was introduced to allow users the ability to disable automatic creation of clients. Unfortunately, the default for pre-existing jobs was not being correctly set. All existing jobs have this option set to false, which can cause build errors in dynamic environments.

If this has happened, and you want to set all jobs back to their original behavior, you can run the following groovy script in the jenkins script console:

hudson.model.Hudson.instance.projects.each{proj ->
  if(proj.scm instanceof hudson.plugins.perforce.PerforceSCM){
    proj.scm.setCreateWorkspace(true);
  }
};

Note that if you went from <=1.3.7 to >=1.3.9, this issue will not affect you.

Version History

Version 1.3.36 - (Feb 11, 2016)

Version 1.3.35 - (June 5, 2015)

Version 1.3.34 - (Feb 2, 2015)

Version 1.3.33 - (Dec 30, 2014)

Version 1.3.32 - Skipped due to the release process issues

Version 1.3.31 - (Dec 10, 2014)

Version 1.3.30 - Skipped due to the release process issues

Version 1.3.29 - (Nov 01, 2014)

Version 1.3.28 - (Oct 10, 2014)

Version 1.3.27 - (Jan 10, 2014)

Version 1.3.26 - (Oct 09, 2013)

Version 1.3.25 - (Sep 09, 2013)

Version 1.3.24 - (May 17, 2013)

Version 1.3.23 - (May 16, 2013)

Version 1.3.22 - (Apr 29, 2013)

Version 1.3.21 - (Apr 12, 2013)

Version 1.3.20 - (Mar 12, 2013)

Version 1.3.19 - (Jan 10, 2013)

Version 1.3.18 - (Nov 28, 2012)

Version 1.3.17 - (Aug 12, 2012)

Version 1.3.16 - (Aug 7, 2012)

Version 1.3.15 - (June 8, 2012)

Version 1.3.14 - (May 14, 2012)

Version 1.3.13 - (April 19, 2012)

Version 1.3.12 - (March 29, 2012)

Version 1.3.11 - (March 26, 2012)

Version 1.3.10 - (March 8, 2012)

Version 1.3.9 - (Feb 28, 2012)

Version 1.3.8 - (Feb 21, 2012) (See the note above if you installed this version)

Version 1.3.7 - (Jan 10, 2012)

Version 1.3.6 - (Dec 12, 2011)

Version 1.3.5 - (Nov 17, 2011)

Version 1.3.4 - (Nov 3, 2011)

Version 1.3.3 - (Sep 29, 2011)

Version 1.3.2 - (Sep 21, 2011)

Version 1.3.1 - (Sep 8, 2011)

Version 1.3.0 - (July 27, 2011)

Version 1.2.9 - (July 15, 2011)

Version 1.2.8 - (July 4, 2011)

Version 1.2.7 - (Jun 20, 2011)

Version 1.2.6 - (Jun 3, 2011)

Version 1.2.5 - (Apr 22, 2011)

Version 1.2.4 - (Mar 24, 2011)

Version 1.2.3 - (Mar 1, 2011)

Version 1.2.2 - (Feb 21, 2011)

Version 1.2.1 - (Feb 18, 2011)

Version 1.2.0 - (Feb 11, 2011)

Version 1.1.14 - (Jan 6, 2011)

Version 1.1.13 - (Dec 7, 2010)

Version 1.1.12 - (Nov 18, 2010)

Version 1.1.11 - (Oct 29, 2010)

Version 1.1.10 - (Oct 6, 2010)

Version 1.1.9 - (Sep 29, 2010)

Version 1.1.8 - (Sep 22, 2010)

Version 1.1.7 - (Sep 16, 2010)

Version 1.1.6 - (Sep 7, 2010)

Version 1.1.5 - (Aug 23, 2010)

Version 1.1.4 - (July 2, 2010)

Version 1.1.3 - (Jun 14, 2010)

Version 1.1.2 - (Jun 11, 2010)

Version 1.1.1 - (Jun 2, 2010)

Version 1.1.0 - (May 21, 2010)

Version 1.0.29 - (Apr 19, 2010)

Version 1.0.28 - (Apr 9, 2010)

Version 1.0.27 - (Apr 5, 2010)

Version 1.0.26 - (Mar 25, 2010)

Version 1.0.25 - (Mar 20, 2010)

Version 1.0.24 - (Mar 12, 2010)

Version 1.0.23 - (Mar 5, 2010)

Version 1.0.22 - (Feb 27, 2010)

Version 1.0.21 - (Feb 19, 2010)

Version 1.0.20 - (Feb 16, 2010)

Version 1.0.19 - (Feb 13, 2010)

Version 1.0.18 - (Feb 1, 2010)

Version 1.0.17 - (Jan 20, 2010)

Version 1.0.16 - (Jan 4, 2010)

Version 1.0.15 - (Nov 19, 2009)

Version 1.0.14 - (July ?, 2009)

Version 1.0.13 - (4/6/2009)

Version 1.0.12 - (5/15/2008)

Version 1.0.11 - (4/22/2008)

Version 1.0.10 - (1/26/2008)

Version 1.0.4 - (11/13/2007)

Version 1.0.3 - (10/26/2007)

Version 1.0 - (10/09/2007)

Version 0.9 - (10/04/2007)

Version 0.5 - (9/29/2007)

Disclaimer

As mentioned above, do NOT use the wiki comments to ask for support! If you have a question, you should ask the mailing list or the irc channel. You should also check the list of open issues on the issue tracker. Failing that, you can contact rpetti directly for assistance.