# Notes: PHP QA Tools + Jenkins PHP Project Template

Published: 2012-04-26

<p>So, after catching&nbsp;<a title="Sebastian Bergmann @s_bergmann" href="https://twitter.com/#!/s_bergmann">Sebastian Bergmann</a>'s&nbsp;<a href="https://twitter.com/#!/s_bergmann/status/195152706762051584">tweet</a> about the <a title="The PHP Quality Assurance Toolchain " href="http://phpqatools.org/">PHP Quality Assurance Tool-chain project</a> 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).</p>
<p>Below are a few notes I took during the global&nbsp;installation&nbsp;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&nbsp;installation&nbsp;process, so there's no QA assurance on this post&nbsp;:) , either way, along with the website you'll be&nbsp;fine and on your way with getting the full tool-chain up and running :)</p>
<h2>Installation notes</h2>
<h2><a href="http://phpqatools.org/">PEAR phpqatools</a></h2>
<pre class="brush:shell">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</pre>
<h3><a href="http://jenkins-ci.org/">Jenkins</a></h3>
<h4><a href="http://pkg.jenkins-ci.org/debian/">DEB Install</a></h4>
<pre class="brush:shell">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</pre>
<h4><a href="http://jenkins-php.org/">Template for Jenkins Jobs for PHP Projects</a></h4>
<pre class="brush:shell">sudo pear install pear.phpqatools.org/phpqatools pear.netpirates.net/phpDox
sudo pear install channel://pear.netpirates.net/phpDox-0.4.0</pre>
<h4>Jenkins CLI</h4>
<blockquote><p>Had to manually update the <a href="http://localhost:8080/pluginManager/advanced">Jenkins Plugins DB</a>&nbsp;via the Web interface, the CLI interface doesn't seem to have an proper command</p></blockquote>
<pre class="brush:shell"># 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</pre>
<h4>Jenkins PHP Template</h4>
<blockquote><p>My Jenkins Home is: /var/lib/jenkins</p></blockquote>
<pre class="brush:shell">cd $JENKINS_HOME/jobs
sudo git clone git://github.com/sebastianbergmann/php-jenkins-template.git php-template
sudo chown -R jenkins:nogroup php-template/</pre>
<p>Also, make sure you have 'ant'&nbsp;installer</p>
<pre class="brush:shell">sudo apt-get install ant</pre>
<h3>Running your first Build</h3>
<ul>
<li>Build Failure #1 - Clone permission denied<br />
Some local .git/objects files hadn't READ permissions for everyone, fixed it with</li>
</ul>
<pre class="brush:shell">chmod -R a+r *</pre>
<ul>
<li>Build Failure #2 - Could not apply tag.&nbsp;Optionally&nbsp;you can do this on the Jenkins Web Interface (job configuration =&gt; git =&gt; repository browser - advanced button )
<pre class="brush:shell">cd $JENKINS_HOME/jobs/project/workspace
sudo -u jenkins git config user.email "jenkins@localhost"
sudo -u jenkins git config user.name "jenkins"</pre>
</li>
</ul>
<p>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&nbsp;instructions&nbsp;of course), in any case, <strong>do</strong> check out <a title="Commands for installing Jenkins for a PHP project on Ubuntu 11.04 server with automatic pulling of code from private Github repository" href="http://hnygard.no/ubuntu/commands-for-installing-jenkins-for-a-php-project-on-ubuntu-11-04-server-with-automatic-pulling-of-code-from-private-github-repository/">this post</a>&nbsp;since it will absolutely get you going with the proper build steps you need to take.</p>
<p>Now, all we need is quality software :)</p>
