First install Jenkins, fortunately it's available in Ubuntu's repositories
$ sudo apt-get install jenkins
By default jenkins runs on port 8080, so if you don't have anything in conflict with that port just pointing your browser to http://localhost:8080 will pop up your jenkins installation
Now we need something to allow Jenkins to execute the unit tests in our code, the most used is PHPUnit, also at the repositories
$ sudo apt-get install phpunit
Jenkins relies on ant to build the code, in fact it is installed as a dependency, so the next thing to do is to write an ant configuration file called build.xml at the application's root
As an example this minimal configuration based on a template found in jenkins site:
Creates a project with several targets, each target can be called using ant like
$ ant target
The main target is build, which cleans the build directory and then executes phpunit, to test it simply type
$ ant build
As you can see phpunit is being called without any parameters, so it relies on it's own xml configuration file named phpunit.xml.dist (not sure if the dist is required) but it works :D
A sample content can be
basically creates a test suite and searches for all files ending in Test.php (like ControllerTest.php) in the specified directories
The logging section allows phpunit to write code coverage metrics and junit reports that jenkins can read
The filter section prevents the execution of the classloader.php since it's our bootstrap for the unit tests
With this file ant has everything to run the build, now moving to jenkins to wrap everything up