Continuous integration with Jenkins – PHP


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.

Please visit http://jenkins-ci.org/ for a detail guide on installing & setting up the Jenkins CI Server environemnt.

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:

wget http://<hostname&gt;:8080/jnlpJars/jenkins-cli.jar

Install the respective plugins in the following manner, hostname – localhost

java -jar jenkins-cli.jar -s http://<hostname&gt;:8080 install-plugin <plugin name>
...
...
...
java -jar jenkins-cli.jar -s http://<hostname&gt;:8080 safe-restart

References

1 Comment

  1. August 24, 2013 at 4:09 pm

    […] one of my previous post I have run through the steps involve in setting up Jenkins and today I’m going to discuss […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: