Symfony2 with Jenkins

Here is a list for common problems found while integrating sf2 and jenkins.

First problem I ran into was that I had set jenkins user on debian to handle all jenkins tasks. git was set to work with my current debian ubuntu account, however when jenkins was working it did not have settings for identity set on git. That was solved running config –global and respetively.

Second problem I ran into was the following warning:

FATAL: Unable to find build script at /var/lib/jenkins/jobs/FormModelProjectBundle/workspace/build.xml

Yes I had to modify build.xml from the website instructions and adapt it and place it at the root of my project folder.

Third problem I found is that I did not have installed ant:

sudo apt-get install ant

After this I got this sucker:

[exec] Cannot find specified rule-set "/var/lib/jenkins/jobs/FormModelProjectBundle/workspace/build/phpmd.xml".

So I added the following under build/ :

<?xml version="1.0" encoding="utf-8" ?>
<phpmd failonerror="off" failonruleviolation="off">

Then it was giving me an error saying that it couldn’t find phpunit. And it is because I had to place -c app as argument and path respectively (check the repo for FormModelProjectBundle).

Then I ran into a problem with the classloaders:

[exec] PHP Fatal error:  Class 'Doctrine\Common\Annotations\AnnotationRegistry' not found in /var/lib/jenkins/jobs/FormModelProjectBundle/workspace/app/autoload.php on line 43

This was because i needed to run a bin/vendors update task into the build:

<target name="vendors"
         description="Update vendors">
  <exec executable="bin/vendors" failonerror="true">
     <arg value="update" />
// and at the end
<target name="build" depends="clean,vendors,parallelTasks,phpunit,phpcb"/>

Then also realized that I had to log somewhere (this code goes inside the phpunit.xml):

        <log type="coverage-html" target="build/coverage" title="Name of Project"
            charset="UTF-8" yui="true" highlight="true"
            lowUpperBound="35" highLowerBound="70"/>
        <log type="coverage-clover" target="build/logs/clover.xml"/>
        <log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/>

You can solve many more problems. If you have found more please post them on comments so we can keep track of common issues.

Also I transferred the ant version to a phing build version here so it can work with phpstorm This you can use with jenkins.

Pushed to git repo and now running jenkins!

Please consider donating for most sf2 posting!

Some of the giants whose shoulders lifted me to see further:

5 thoughts on “Symfony2 with Jenkins

  1. public function onCoreController(FilterControllerEvent $event){
        $controller = $event->getController();
        $shortCuts = array(“page”, “website”, “breadcrumb”, “cache”, “em”, “request”, “router”, “user”, “post”);
        foreach ($shortCuts as $shortCut){
            if (property_exists($controller[0], $shortCut)){
                if (is_null($this->$shortCut)){
                    switch ($shortCut){
                        case “post”: $this->initPost(); break;
                        case “em”: $this->initEntityManager(); break;
                        case “user”: $this->initUser(); break;
                        case “router”: $this->initRouter(); break;
                $controller[0]->$shortCut = $this->$shortCut;
  2. It’s also a good idea to have the build run the following command to make sure you don’t have any cache problems:

    php app/console cache:clear –no-warmup

  3. Very helpful.

    However, I would advise using install rather than update for the vendors script. This will make sure you use the versions specified by the developers and have a stable build. Updating the vendors should require manual intervention.

  4. Hello, how did you manage to modify the build.xml file? i need to modify it while the build is executed to add some information but it’s created in the end. I tried also with post build tas plugin but it’s not created yet. Thank you very much

Leave a Reply to Celia Cancel reply

Your email address will not be published. Required fields are marked *