Setting up Jenkins for a PHP projects on CentOS 7

Philippe Lafrance
Sep 22, 2015 · 4 min read

Setup a Virtual Private Server

Set yourself up for your PHP project

yum install php php-pear
yum install php-intl php-mbstring php-xml php-fileinfo
memory_limit = 1024M
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/bin/composer
yum install php-devel
yum groupinstall "Development tools"
pecl install xdebug
echo "zend_extension=\"/usr/lib64/php/modules/xdebug.so\"" > /etc/php.d/xdebug.ini

Install Jenkins

yum install java-1.7.0-openjdk
yum install wget
wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
yum install jenkins
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --reload
yum install ant
sudo /etc/init.d/jenkins restart
systemctl restart jenkins.service

Install PHP Tools (optional)

# PhpUnit
wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
mv phpunit.phar /usr/bin/phpunit
# Php CodeSniffer
pear install PHP_CodeSniffer-2.3.4
# PHPLOC
wget https://phar.phpunit.de/phploc.phar
chmod +x phploc.phar
mv phploc.phar /usr/bin/phploc
# PDepend
wget http://static.pdepend.org/php/latest/pdepend.phar
chmod +x pdepend.phar
mv pdepend.phar /usr/bin/pdepend
# PHPMD
wget http://static.phpmd.org/php/latest/phpmd.phar
chmod +x phpmd.phar
mv phpmd.phar /usr/bin/phpmd
# PHPCPD
wget https://phar.phpunit.de/phpcpd.phar
chmod +x phpcpd.phar
mv phpcpd.phar /usr/bin/phpcpd
# phpDox
wget http://phpdox.de/releases/phpdox.phar
chmod +x phpdox.phar
mv phpdox.phar /usr/bin/phpdox

Setup Jenkins

User permissions

Plugins

Create a project

cp /my/favorite/path/build.xml ./
<?xml version="1.0" encoding="UTF-8"?>
<project name="requirejs" default="default">
<target name="default" depends="composer,phpunit" /> <target name="composer">
<exec executable="composer">
<arg value="update"/>
</exec>
</target>
<target name="phpunit" depends="composer">
<exec executable="phpunit">
<arg path="${basedir}/phpunit.xml.dist"/>
</exec>
</target>
</project>

Philippe Lafrance

Written by

Programmer, Bassist, and social crack smoker.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade