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

Workarounds found for Huawei e220 on ubuntu 11.10


Once upgrading form Ubuntu 11.04 to 11.10 the Huawei E200 modem failed to work, unfortunately I switched back to Windows 7 for browsing the Internet. I didn’t realized that I would have search for this issue in the first place and today only I just did it, viola I managed to find some workarounds to get my good old Huawei E200 modem back to work 🙂

  • Adding the “blacklist usb_storage” to /etc/modprobe.d/blacklist.conf
  • sudo usb_modeswitch -v 0x12d1 -p 1003 -V 0x12d1 -P 1003 -R

As usual pluagged in the modem and ran the command illustrated under second point and now I’m happily surfing the Internet.

Following was the message got printed on the terminal.


hayesha@gnu-user:~$ sudo usb_modeswitch -v 0x12d1 -p 1003 -V 0x12d1 -P 1003 -R
[sudo] password for hayesha:

Looking for target devices ...
Found devices in target mode or class (1)
Looking for default devices ...
Found devices in default mode, class or configuration (1)
Accessing device 003 on bus 001 ...
Getting the current device configuration ...
OK, got current device configuration (1)
Using endpoints 0x02 (out) and 0x82 (in)
Not a storage device, skipping SCSI inquiry

USB description data (for identification)
-------------------------
Manufacturer: HUAWEI Technologies
Product: HUAWEI Mobile
Serial No.: not provided
-------------------------
Warning: no switching method given.
Resetting usb device .
OK, device was reset
-> Run lsusb to note any changes. Bye.

hayesha@gnu-user:~$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 003: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 HSDPA Modem / E230/E270 HSDPA/HSUPA Modem
Bus 001 Device 004: ID 03f0:231d Hewlett-Packard
Bus 002 Device 003: ID 064e:f209 Suyin Corp.

Reference:- https://bugs.launchpad.net/ubuntu/+source/modemmanager/+bug/868034