Summary
Integrates Hudson with Perforce SCM Repositories.
With this plugin you can use a workspace (formerly known as Clientspec in Perforce speak) that will synchronize files to the Hudson workspace. At the moment, this plugin supports:
- Polling
- Synchronizing
- Browsing latest changes
- Labeling builds (tagging)
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 Hudson, 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 Hudson.
Usage
- Allow the plugin to communicate with Perforce...
- 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 Hudson. And you must not specify the P4CLIENT environment variable because this will overwrite anything that Hudson is trying to do.
- Create a workspace (clientspec) for the plugin to use. Name it "hudson" or something.
- Ensure that the workspace matches your development settings for your project (e.g., LineEnd, Options, etc.)
- Important Note: If you will be concurrently building multiple projects from Perforce, it would be best to create a Perforce workspace for each project.
- Install the plugin. Download it here.
- Create a new project, under "Source Code Management," choose Perforce.

- Enter your server specific details along with the information for the user that Hudson 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.

- Under Build Triggers, check "Poll SCM."

- Save your changes and let Hudson 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
- If Hudson's copy of the project is modified outside of Perforce (say a user deletes the entire project within the workspace directory), the builds following will likely fail. This is because the local copy is out of sync with what is in the depot. Perforce tracks what you have sync'd via the workspace and the way to bring down files that you deleted "accidentally" is to do a "force" sync. If this happens, you can use the option "One Time Force Sync" in the project configuration screen. The next time a build is triggered, p4 sync will be run with the -f option.
- Perforce has specific issues when projects within a depot exist in different local locations that don't map directly to the depot. This is precisely how Hudson operates. To get around this requirement, we have to do some non-standard things. Every build will grab the Perforce workspace and then modify it to suite the needs of the current Hudson project. It then syncs the projects files and performs the build. This means that no two projects utilizing the same Perforce workspace should be built at the same time. It is unknown what will happen if you are synchronizing with one build, but another build attempts to modify the same Perforce workspace. It will probably be Not Good(tm). If builds must be performed concurrently, multiple workspaces can be used to get around this.
Version History
Version 1.0.12 - (5/15/2008)
- Fixed issue: 1163, Sync'ing on Hudson Slaves is now supported. Thanks go to Victor (vicsz).
- Fixed issue: 1681, Labeling builds on JVMs earlier than 1.6 were failing.
Version 1.0.11 - (4/22/2008)
- Fixed issue: 1313, Sync'ing to Perforce labels is now supported.
- Added enhancement: 1374, Hudson user's email address is retrieved from Perforce user account if it exists.
Version 1.0.10 - (1/26/2008)
- Fix issues: 1070, 1072, 1073/1100, 1092, 1093
- Now supports changelists with purged files.
- The current changelist number is available as an enviroment variable: P4_CHANGELIST. Thanks go to Eike and gerhard6.
- Fixed changelist parsing with certain versions of Perforce, thanks go to Kiril.
- Fixed il8n parsing of changelists, thanks go to gerhard6.
- Using the latest P4Java version, 0.7.5.
Version 1.0.4 - (11/13/2007)
- Support for polling/sync'ing with multiple views in a single workspace
- Uses new P4Java version that supports Perforce security level 3
- Fixed issue when prior build does not have any changes
Version 1.0.3 - (10/26/2007)
- Fixed issue where the last sync'd changelist would be lost on a restart of Hudson. This resulted in the next build after a restart being marked as containing all prior changes.
- Fixed issue with improper XML encoding of changelist history.
- Fixed issue with invalid characters in XML of changelist history.
- Fixed issue where a manual build would always be marked as failed if there were no new changes present.
- Changed validation to allow project paths that start with something other than //depot/
- Fixed problem with changelist icons not showing up on unix systems.
- Fixed NPE on first build of a new project
- Added ability to specify first change to record history from
- Added ability to use workspace with custom views specified by end user.
Version 1.0 - (10/09/2007)
- Support for repository browsing with P4Web and Fisheye
- Support for tagging of builds (Referred to as Labels in Perforce, so that is what is used in the plugin)
- Support for doing a force sync to head (allowing Hudson to bring down all project files)
- Perforce security level 3 is supported on unix systems. Windows currently requires a workaround.
- Fixed bug on unix systems where workspace root was incorrect.
- Validation of Perforce settings is now done on configuration page.
- The Perforce workspace (clientspec) descriptions are no longer lost after a build.
Version 0.9 - (10/04/2007)
- Production ready release. Includes support for displaying change history. Perforce specific details, such as Jobs, are included in reporting.
Version 0.5 - (9/29/2007)
- Initial release. Includes support for polling and synchronizing. Repository browsing and latest changes still to come.
Comments (11)
Oct 25, 2007
Anonymous says:
Nice\! Have been waiting for Perforce support.Nice! Have been waiting for Perforce support.
Feb 18, 2008
Anonymous says:
Nice plugin. Unfortunately this plugin (v1.0.10) can not check out from a label ...Nice plugin. Unfortunately this plugin (v1.0.10) can not check out from a label yet, see https://hudson.dev.java.net/servlets/BrowseList?list=dev&by=thread&from=976444
Apr 22, 2008
Mike Wille says:
Version 1.0.11 now supports this.Version 1.0.11 now supports this.
Feb 27, 2008
Felipe Leme says:
In my environment, when a file is deleted Hudson does not detect it. It might be...In my environment, when a file is deleted Hudson does not detect it. It might be a Perforce configuration issue, but thanks to Hudson's flexibility, I could provide a quick workaround by enabling the "Shell script" option and adding the following command:
p4 sync "$PWD/..."
(sure, it's a Unix-only trick, but I don't even consider running CI on Winblows
Apr 22, 2008
Mike Wille says:
The Perforce plugin for Hudson interacts directly with the P4 client so there sh...The Perforce plugin for Hudson interacts directly with the P4 client so there should be no need to run this command. I wonder if the workspace is being used in multiple projects? It might be thinking the file was already removed when executed from the other project. Though it sounds like you are fine with it, this can be fixed if you wish to pursue it.
Feb 28, 2008
Anonymous says:
Hi, Trying to use this plugin with our version of perforce (2003.2 56323), but a...Hi,
Trying to use this plugin with our version of perforce (2003.2 56323), but am getting these error:Caught Exception communicating with perforce. Error in client specification. Error detected at line 7. Null directory (//) not allowed in '///...'.
For Command: p4 -s client -i
With Data:
===================
Client:
Description:
Root: C:\Development\XP\CI\Hudson\jobs\Framework\workspace\
Options:
LineEnd:
View:
//depot/Framework/current/... ///...
Why isnt there a clientspec name in the view definition?
Thanks
Mike
Apr 22, 2008
Mike Wille says:
This looks to be the same problem described here: https://hudson.dev.java.net/is...This looks to be the same problem described here:
https://hudson.dev.java.net/issues/show_bug.cgi?id=1070
I believe that 2003.x and earlier servers do something different that the Perforce library does not support. Unfortunately, the oldest version of Perforce I can get my hands on is 2005. So I can't even reproduce the problem.
Jul 21
Danny Aden says:
I have run into a similar issue, with a different error message running P4 serve...I have run into a similar issue, with a different error message running P4 server version (Server 2006.1/109255.).
I assumed this error meant that the client needed the environment variable P4CHARSET=utf8, but I have tried setting this in the environment variables with no luck and didn't see a way to specify it through the plugin. I noticed that the client workspace appears to be null as the plugin tries to set the client view to ///... so it seems like this might be related.
Here is the error from the logs:
======
workspace $ p4 workspace -o bld-blbaker-a7-blaze-windows-continuous-hudson
Changing P4 Client Root to: c:\tomcat6\webapps\hudson\jobs\blaze-continuous\workspace\
Changing P4 Client View to: //blaze/trunk/... ///...
workspace $ p4 -s client -i
Caught Exception communicating with perforce. Unicode server permits only unicode enabled clients.
======
Any ideas of what I am doing wrong? I tried running "p4 -u bld -s client" from a comand prompt and it seems to work fine (-u bld is because I am running as a different p4 user than the user logged into the build box).
Thanks,
~D
Apr 18, 2008
Bila Nagirner says:
Hello, When building on a slave machine our code is being checked out on t...Hello,
When building on a slave machine our code is being checked out on the master machine. Is there anyway to get it to checkout to the slave machine?
Thanks,
Bila
Apr 22, 2008
Mike Wille says:
Not yet, unfortunately. See this issue for updates: https://hudson.dev.java.net/...Not yet, unfortunately. See this issue for updates:
https://hudson.dev.java.net/issues/show_bug.cgi?id=1163
Nov 06
LeoT says:
Hi,\\ Is it possible to name a build by latest change list number ?\\ Is it poss...Hi,
Is it possible to name a build by latest change list number ?
Is it possible to add change list number to notification emails ?