Translation of my article on how to set up an assembly for PHP projects based on symfony2 using Jenkins.Recently, I was faced with the task of setting it up specifically for the Symfony 2.1 + Jenkins + PHPUnit + PHPCodeSniffer + PHPMessDetector + PDepend set.
I hope this short article will be useful! Today I will explain how to install and configure an assembly for Symfony2 projects using Jenkins and PHP templates for Jenkins projects , created by Sebastian Bergmann .
The configuration works stably with Jenkins v.1.480.1 and projects based on the symfony v.2.1 framework. ')
move the folder with Jenkins to [SYMFONY2_ROOT] / app / Resources / inside your Symfony2 project;
move the build.xml file to the root of your symfony2 application;
move the phpunit.xml file to the [SYMFONY2_ROOT] / app folder or update the existing file. The logging node is necessary if you want to profile and log unit test reports;
If you get the error "PHP Fatal error: Class 'XSLTProcessor' not found in /usr/share/php/TheSeer/fXSL/fxsltprocessor.php on line 58 ", you can fix it as follows:
sudo apt-get install php5-xsl
You may also get the error " PHP Warning: require (/ var / lib / jenkins / jobs / TestJob / workspace / app /../ vendor / autoload.php): lib / jenkins / jobs / TestJob / workspace / app / autoload.php on line 5 "because we use symfony v2.1 , which composer pipes. You can eliminate it in the following way:
add composer step to your build.xml . How to do this is described in this article ;
If you continue to receive this message after adding the composer step, you may need to add a dependency for PHPunit from the composer : depends = ”composer” ;
Sometimes you may have a problem in the “vendors” step, in which you see something like:
[exec] The deps file is not valid ini syntax. Perhaps missing a trailing newline? [exec] PHP Warning: parse_ini_file(/var/lib/jenkins/jobs/TestJob/workspace/deps): failed to open stream: No such file or directory in /var/lib/jenkins/jobs/TestJob/workspace/bin/vendors on line 69
You can fix this by removing vendors from the build dependency and vendors target block in the build.xml script
if you get the Status: 2 result at the step codesniffer step (phpcs), you need to set the Symfony2 coding standard that you can take on this resource ;
enable the “Poll SCM” option and enter it below: * / 5 * * * * (by enabling this option, you give Jenkins instructions to check the project repository for 5 minutes every 5 minutes. If changes (commits) are found, Jenkins automatically starts the build project).
It's all! Now you are ready to build your PHP Symfony2 project using Jenkins! If you find any errors (or corrections), useful links, or if you have other suggestions, leave comments here or in the original article.