Notes: PHP QA Tools + Jenkins PHP Project Template

So, after catching Sebastian Bergmann's tweet about the PHP Quality Assurance Tool-chain project I was at last reunited with an old goal of mine, to get some tools to oversee my mess (and there's plenty of it to go around).

Below are a few notes I took during the global installation process, applied to my reality (Ubuntu), it all went about well the first time, I had built setup related issues (they're in the notes down there, rookie mistakes and particular conditions) . They're straight out of my installation process, so there's no QA assurance on this post :) , either way, along with the website you'll be fine and on your way with getting the full tool-chain up and running :)

Installation notes

PEAR phpqatools

sudo pear config-set auto_discover 1
sudo pear install pear.phpqatools.org/phpqatools
sudo pear channel-discover pear.phpdoc.org
sudo pear install phpdoc/phpDocumentor-alpha
sudo pear install channel://pear.php.net/Text_Highlighter-0.7.3

Jenkins

DEB Install

wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo vim /etc/apt/sources.list
# Add the following line
# deb http://pkg.jenkins-ci.org/debian binary/
sudo apt-get update
sudo apt-get install jenkins

Template for Jenkins Jobs for PHP Projects

sudo pear install pear.phpqatools.org/phpqatools pear.netpirates.net/phpDox
sudo pear install channel://pear.netpirates.net/phpDox-0.4.0

Jenkins CLI

Had to manually update the Jenkins Plugins DB via the Web interface, the CLI interface doesn't seem to have an proper command

# Get the jenkins-cli jar file
wget http://localhost:8080/jnlpJars/jenkins-cli.jar

# Install the plugins
java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin analysis-core checkstyle cloverphp dry htmlpublisher jdepend plot pmd violations xunit git

# Restart Jenkins
java -jar jenkins-cli.jar -s http://localhost:8080 safe-restart

Jenkins PHP Template

My Jenkins Home is: /var/lib/jenkins

cd $JENKINS_HOME/jobs
sudo git clone git://github.com/sebastianbergmann/php-jenkins-template.git php-template
sudo chown -R jenkins:nogroup php-template/

Also, make sure you have 'ant' installer

sudo apt-get install ant

Running your first Build

  • Build Failure #1 - Clone permission denied
    Some local .git/objects files hadn't READ permissions for everyone, fixed it with
chmod -R a+r *
  • Build Failure #2 - Could not apply tag. Optionally you can do this on the Jenkins Web Interface (job configuration => git => repository browser - advanced button )
    cd $JENKINS_HOME/jobs/project/workspace
    sudo -u jenkins git config user.email "jenkins@localhost"
    sudo -u jenkins git config user.name "jenkins"

At this point, you're about ready to go, mind you, you have a pretty empty build right there (unless your project is already configured with build instructions of course), in any case, do check out this post since it will absolutely get you going with the proper build steps you need to take.

Now, all we need is quality software :)