Jenkins for php project on centos 6.2

After setting up Jenkins for use in my work place, I had to document how to set up in the past couple days. I thought I would share it here.

OS: CentOS release 6.2 (Final)
[—— ~]$ cat /proc/version
Linux version 2.6.32-220.23.1.el6.x86_64 ( (gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC) ) #1 SMP Mon Jun 18 18:58:52 BST 2012
[—— ~]$ uname -a
Linux jenkins.sometrics 2.6.32-220.23.1.el6.x86_64 #1 SMP Mon Jun 18 18:58:52 BST 2012 x86_64 x86_64 x86_64 GNU/Linux

Prerequisites prior to Jenkins

java-1.6.0-openjdk.x86_64 (64bits) - as of Jun 27, 2012
1. sudo yum install java-1.6.0-openjdk(this will pull these dependencies)
- giflib
- jline
- jpackage-utils
- rhino
- tzdata-java
2. actual version is 1:
Apache Ant 1.7.1 - as of Jun 27, 2012
1. sudo yum install ant (this will install these dependencies)
- java-1.5.0-gcj
- java-1.6.0-openjdk-devel
- java_cup
- libgcj
- sinjdoc
- xerces-j2
- xml-commons-api
- xml-commons-resolver
2. actual version is 1.7.1-13.el6

1. sudo rpm -Uvh
2. sudo yum install php54w php54w-cli php54w-common php54-dba php54-devel php54-gd php54-intl php54-mbstring php54-mysql php54-odbc php54-pdo php54-pear php54-process php54-xml (this will install these dependencies)
- autoconf
- automake
- libXpm
- libicu
- unixODBC

1. sudo pear upgrade PEAR
2. sudo pear channel-discover
3. sudo pear channel-discover
4. sudo pear channel-discover
5. sudo pear channel-discover
6. sudo pear channel-discover
7. sudo pear install --alldeps phpunit/PHPUnit
8. sudo pear install phpunit/DbUnit
9. sudo pear install phpunit/phpcpd
10. sudo yum install ImageMagick-devel (This will install these dependencies)
- bzip2-devel
- ghostscript-devel
- jasper-devel
- lcms-devel
- libICE-devel
- libSM-devel
- libX11-devel
- libXau-devel
- libXdmcp-devel
- libXext-devel
- libXt-devel
- libgomp
- libjpeg-devel
- libtiff-devel
- libwmf-lite
- libxcb-devel
- xorg-x11-proto-devel
- zlib-devel
11. sudo pear install --alldeps pdepend/PHP_Depend
12. sudo pear install theseer/phpDox-0.4.0 (note: this can take a while. Be patient)
13. sudo pear install PHP_CodeSniffer
14. sudo pear install --alldeps phpunit/PHP_CodeBrowser
15. pear channel-discover (it’s not working currently...)
16. sudo pear install phpmd/PHP_PMD (this will fail.... maybe server is down as of now and will be back up tomorrow perhaps? For now skip it.)

To install Jenkins through yum
1. sudo wget -O /etc/yum.repos.d/jenkins.repo
2. sudo rpm --import
3. sudo yum install jenkins
4. sudo service jenkins start/stop/restart

Jenkins should be accessible through port 8080
Make sure iptable opens the port 8080 from outside

Install Jenkins Plugins
1. go to http://{}:8080
2. Click on “Manage Jenkins” link from side menu
3. Click on “Manage Plugins” link from the page
4. Click on “Available” Tab
5. Check these plugins (Some might be missing because they could be already installed)
- External Monitor Job Type Plugin
- ant
- Static Code Analysis Plug-ins
- Subversion Plugin
- HTML Publisher plugin
- Jenkins Translation Assistance plugin
- Jenkins SSH Slaves plugin
- PMD Plugin
- Jenkins Clover PHP plugin
- Publish Over SSH
- Green Balls
- Jenkins Violations plugin
- Plot plugin
- Measurement Plots
- xUnit plugin
- Hudson SCP publisher plugin
- Checkstyle Plugin
- DRY Plugin
- Jenkins JDepend Plugin
6. Click on “Download now and install after restart”

There gotta be something I missed, but this instruction should be a good start to set up jenkins on centos 6.2 for any PHP development work.

Happy CI'ing! :)

mysqldump tip

mysqldump is a command line tool for exporting mysql data.
This tool also can be used to generate seed xml files for php dbunit.
And this is how you can achieve that.

mysqldump -u {user} -t –xml –databases {dbname} –tables {tablename} > filename.xml

The above command will generate a xml file that PHP DBUnit understands.

And then inside phpunit class file, you would be using it like this:

protected function getDataSet()

$seed = $this->createMySQLXMLDataSet(dirname(__FILE__).’/filename.xml’);
$datesets = array($seed);

$compositeDs = new PHPUnit_Extensions_Database_DataSet_CompositeDataSet($seed);

return $compositeDs;


upgrading PEAR in centos 5.8

My OS was centos 5.8 and was trying to install Phing for PHP Application packaging. However, installation would fail because of the old PEAR that I had. The pear that I had was from yum installation.

It turned out that I had to manually upgrade to the latest pear and the instruction that I found was at:

If old pear from the installation via YUM is on the OS, even updating PEAR itself would fail. Only way to upgrade is to do it manually per the instruction.

php go-pear.phar

The one that I used for the base dir during the installation was :

/usr/share/pear instead of /home/${USER}/pear.

meta tags for iphone site

Currently I’m working on a site that is expected to work fine on iPhone devices. Obviously I knew that I had to dig up meta tags for iPhone site for Safari on the iPhone devices.

Found this and here are the list of it:

  • <meta name=”apple-mobile-web-app-capable” content=”yes”> : sets whether a web application runs in full-screen mode. (refer to the documentation for the potential values)
  • <meta name=”apple-mobile-web-app-status-bar-style” content=”black”> : Sets the style of the status bar for a web application. (refer to the documentation for the potential values)
  • <meta name=”format-detection” content=”telephone=no”> : Enables or disables automatic detection of possible phone numbers in a webpage in Safari on iOS.
  • <meta name = “viewport” content = “width = 320,
    initial-scale = 2.3, user-scalable = no”> : Changes the logical window size used when displaying a page on iOS.

Mostly I was using viewport. 🙂

Tips on how to write a resume for web developer/engineer

I’ve been screening a lot of resumes these days to fill out one open position in our team. However, most of resumes that I reviewed writes about what projects were about and what role the candidate was on.

I rejected most of those resumes and sent back to recruiter.

Resume is a representation of you as an developer/engineer. As an engineer, don’t you want to discuss how you solve an puzzle instead of telling me what the puzzle was all about, what the rule the puzzle had, and so on?

I am looking for a resume that shows me how you solved an issue, how you improved performance, why you chose this approach over that approach, and so on.

In summary, I’d like to see more details on how and why you do.

pulling query string in node.js

in web development, pulling data from query string is the basic and fundamental task. In node.js, the syntax is like this:

you can actually test my test app here: