With one of my previous post I have run through the steps involve in setting up Jenkins and today I’m going to discuss about the how to get a PHP project integrated with Jenkins on a Mac Mini server(It’s a pain in the ass compared to a Linux box when it comes to setting up Jenkins server).
List of items required
We need to enable and install following modules both on Jenkins as well as on PHP.
- HTML Publisher
- JSHint Report
- Apache Ant
- Jenkins Email Extension
- PHP modules using the PEAR package
Install modules and plugins
Alright, we have list down the items and now lets see how to install each items.
Installation of Jenkins modules
Navigates to Jenkins » Manage Jenkins » Plugin Manager.
Under this section you’ll find four tabs, namely Updates, Available, Installed, Advanced. Select Available tab and tick the above mentioned list of plugins from the list and click on the Install without restart button.
Installation of required PHP modules via PEAR package
Please make sure that you have installed the PHP PEAR package before proceeding with the below steps.
- phploc – A tool for quickly measuring the size of a PHP project.
$ sudo pear config-set auto_discover 1
$ sudo pear install pear.phpunit.de/phploc
pdepend – Metrics analysis tool for software developed in PHP.
$ sudo pear channel-discover pear.pdepend.org
$ sudo pear install pdepend/PHP_Depend-beta
phpmd – It takes a given PHP source code base and look for several potential problems within that source.
$ sudo pear channel-discover pear.phpmd.org
$ sudo pear install phpmd/PHP_PMD
$ sudo pear install PHP_CodeSniffer
phpcpd – It is a Copy/Paste Detector (CPD) for PHP code.
$ pear install pear.phpunit.de/phpcpd
phpdox – It is a documentation generator for generating API documentation in HTML format, for instance, from PHP source code.
$ sudo pear install -f pear.netpirates.net/phpDox-0.5.0
phpunit – It is a documentation generator for generating API documentation in HTML format, for instance, from PHP source code.
$ sudo pear channel-discover pear.phpunit.de
$ sudo pear install phpunit/PHPUnit
phpcb – It is a documentation generator for generating API documentation in HTML format, for instance, from PHP source code.
$ sudo pear channel-discover pear.phpqatools.org
$ sudo pear install --alldeps phpqatools/PHP_CodeBrowser
Fixing the issue:
When you execute Build Now from the project’s menu you’ll notice that following message is displayed under Console Output section.
[exec] Warning: require(PHPCPD/Autoload.php): failed to open stream: No such file or directory in /usr/bin/phpcpd on line 49
[exec] Fatal error: require(): Failed opening required 'PHPCPD/Autoload.php' (include_path='.:') in /usr/bin/phpcpd on line 49
Where ever your encounter a similar error please place the following block of code on the top of the respective script. This required script can be found under
/usr/bin. For example with phpcpd place the following block of code.
$path = '/usr/lib/php';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);