Jenkins for CodeIgniter

Continues Integration is Software practice which is used to improve the software quality and make sure the Coding Standard and style of the organisation .

Setup Environment :
Install the following item
a) setup PHPUnit
sudo pear upgrade PEAR
sudo pear config-set auto_discover 1
sudo pear install
sudo pear install phpunit/DbUnit

b) Jenkins Setup
sudo apt-get update
sudo apt-get install jenkins

c) Downloading the necessary files and install in to the existing projects
d) PHP CodeSniffer
sudo pear install PHP_CodeSniffer

e) PHP Mess Detector / (PHP_MD)
sudo apt-get install php5-dev
sudo pear channel-discover
sudo pear channel-discover
sudo pear install –alldeps phpmd/PHP_PMD

g) PHP Depend
sudo pear channel-discover
sudo pear install pdepend/PHP_Depend-beta

h) Installing PHPCPD (PHP Copy paste detector)
pear channel-discover
pear install phpunit/phpcpd

i) php_ab Installation
sudo wget -N –no-check-certificate -O /bin/phpab
sudo chmod +x /bin/phpab

j) ANT Setup
apt-get install ant php5-xsl php5-xdebug libxml2-utils

How to setup the environment for CodeIgniter
In order to run PHPUnit there are some modfications needed in some files and wanted to create some new files .

$config[‘uri_protocol’] = ‘REQUEST_URI’;//’AUTO’; line 64
$config[‘enable_hooks’] = TRUE;//FALSE; line 125

// application/config/hooks.php
$hook[‘display_override’] = array(
‘class’ => ‘DisplayHook’,
‘function’ => ‘captureOutput’,
‘filename’ => ‘DisplayHook.php’,
‘filepath’ => ‘hooks’

// application/hooks/DisplayHook.php
class DisplayHook {
public function captureOutput() {
$this->CI =& get_instance();
$output = $this->CI->output->get_output();
if (ENVIRONMENT != ‘testing’) {
echo $output;

Modification on system/core/Utf8.php:
$CFG =& load_class(‘Config’, ‘core’);

Create a new folder called “tests” in to the project root directory
Folder hierarchy


Screenshot from 2014-01-09 13:59:14


Copy the index.phhp and chagned the environment as testing
define(‘ENVIRONMENT’, ‘testing’);
and add the following things
$system_path = realpath(dirname(__FILE__)).’/../elephanti/system’;
$application_folder = realpath(dirname(__FILE__)).’/../elephanti/application’;

Sample PHPUnit test:

DBUnit testing:
how to take DB xml schema thorug terminal
mysqldump –xml -t -u root -p dbname > db-seed.xml

Sample DBunit testing
It will come soon

Accessing Jenkins:

How to run the unit test with ant

go to root directory and run “ant -f build.xml”


How to run the unit test with PHPUnit


Creating a new job in jenkins
screenshot-by-nimbus-192-168-1-40-8080-job-Shop_unit-configure (1)


2 thoughts on “Jenkins for CodeIgniter

  1. Hi, Thakns for ur great article.I have some when i build the project jenkins says that WARNING: clock of the subversion server appears to be out of sync. This can result in inconsistent check out behavior.

Leave a Reply

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

You are commenting using your 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