Build automation, the practice of automating various tasks that software developers need to perform in their daily routine. These tasks usually include the compilation of source code into binary code and the running of automated tests as well as the packaging and possibly even the deployment of the resulting binaries. Although PHP is an interpreted language and does not use an explicit compilation step it is common to perform code generation or code transformation tasks during a build nowadays.
Jenkins, an Open Source Continuous Integration(CI) tool, is by far the most popular CI tool on the market. Although I’ll be focusing on a PHP project, Jenkins CI tool can be configured to used for various projects that uses different programming languages.
I got the change to setup Jenkins to monitor our PHP project and hoping to set it up for the Android and iPhone projects. The book mentioned at the end of this post nicely guides the reader towards successfully setting up and configuring a PHP project to work with Jenkins.
Next step would be to install the required PHP Pear packages
$ sudo pear upgrade PEAR
$ sudo pear config-set auto_discover 1
$ sudo pear install pear.phpqatools.org/phpqatools pear.netpirates.net/phpDox
Above pear packages are required to function following plugins on Jenkins
- PHPUnit is the de-facto standard for the unit testing of PHP code.
- PHP_CodeSniffer is the most commonly used tool for static analysis of PHP code. It is typically used to detect violations of code formatting standards but also supports software metrics as well as the detection of potential defects.
- phpcpd (PHP Copy/Paste Detector) searches for duplicated code in a PHP project.
- PHP_Depend is a tool for static code analysis of PHP code that is inspired by JDepend.
- phpmd (PHP Mess Detector) allows the definition of rules that operate on the raw data collected by PHP_Depend.
- phploc measures the scope of a PHP project by, among other metrics, means of different forms of the Lines of Code (LOC) software metric.
- PHP_CodeBrowser is a report generator that takes the XML output of the aforementioned tools as well as the sourcecode of the project as its input.
- phpdox for automated API documentation generation for PHP code
Final step is to install the plugins required to integrate PHP projects for Jenkins CI Server. There are more than 500 plugins to choose from. The installation of the plugin(s) can be achieved either by using the Web-based interface or using the Jenkins command line interface, which can be downloaded as follows:
Install the respective plugins in the following manner, hostname – localhost
- Integrating PHP projects with Jenkins, by Sebestian Bergmann