I've installed JenkinsCI on our dev server to start automating our dev build and test process. I'm using Jenkins with the Git Plugin and some Drush commands via a shell script.

When researching how to use Jenkins in my Drupal dev workflow, I came across a post about using Phing with Drush and Jenkins. So I looked at Phing and I can't see what it does that cannot be done by using Drush commands via a shell scripts.

I'm trying to decide if it makes sense for me to invest the time in learning how to use Phing. I'm looking for some clarity as to what benefit I will gain by incorporating Phing vs. Drush commands via Shell script.

So my question is for those who use Phing with Drush and Jenkins: how is it that Drush/Drush-Make and Phing differ? Why did you decide to start using Phing in your process?


4 Answers 4


The answer is that they are certainly not redundant.

It's true that one can accomplish the same end result using a bash script that includes drush commands (at least the building part). But, if what we are looking to do is to integrate our process into a CI framework like JenkinsCI, then using something like phing (ant or capistrano could be substituted here) is the way to go.

With phing we can break up the build process into distinct segments that can report back to Jenkins in an intelligent way.

So for example. Say that as part of my build process I use drush to enable two modules, node and shouldfail. Then the build should fail. But if all we do is tell JenkinsCI to run the following shell command, JenkinsCI will say that the build PASSED:

drush --quiet --yes @staging en node shouldfail

Clearly that's not right. However if instead we use ant or phing to define the same process, we can also add some fail logic that Jenkins understands, and therefore fail as it should. The following phing build script tries to do the same thing as the former command, but fails as we expect it to:

<project name="staging" default="enable modules" description="Jenkins Staging Build">

    <target name="enable modules">
      <exec  command="drush --quiet --yes @staging en node shouldfail" error='error' checkreturn="true">
      <loadfile  property="en.error" file="error" />
        <contains string="${en.error}" substring="warning" />
          <property name="en.fail" value="Could not enable all modules" />
      <fail if="en.fail" message="${en.fail}" />


BTW ant and phing are almost identical. The advantage for PHP developers in using phing is that they can more comfortably extend phing.

As for Drupal development and drush being as good as it is, I don't see too much value in extending phing, and think that running exec tasks would suffice to create a smart build template.

Well, in order to answer my question I ended up investing the time to figure out phing. It's actually pretty intuitive and it doesn't take too long to figure out.


There is a Drush task available for Phing now:

Instead of using exec you can include Drush comands like this...

  <drush command="site-install" assume="yes"">
        <option name="locale">uk</option>
        <option name="site-name" value="${sitename}" />
  • I used used the drushtask for a little and I couldn't successfully interact with drush warnings. I ended up dropping it because for that reason and the fact that I found it limiting in other respects.
    – DKinzer
    Sep 17, 2012 at 12:43
  • It would be nice to explain the issues/limits you had with Drush task in support or feature request on its issue queue (drupal.org/project/issues/phingdrushtask). To let others find out and maybe contribute answers. Feb 28, 2013 at 16:16

Phing scripts are replacements for shell scripts, to control the execution of multiple commands and their results. Drush is a CLI interface for commands to interact with a Drupal site or related to Drupal. They complement each other.


Your question: Does Phing and Drush overlap?

TLDR; version: Sorta. But mostly no.

The unabridged version: Drush and phing do overlap in only a few instances. Mainly, dumping and archiving a website would be one of the larger overlaps. You could do it in phing but you would have to write a lot of tasks. You could Dump a database but drush does it so easily with one command. Phing does do that but you just have to write a command line script. Where phing shines is the ability to run phpunit tests, run external tools like a jar that compresses your css files, create and package a build of your drupal site/application, etc.

What is phing?

Phing is essentially the pilot that executes commands. If you're familiar with Ant, Phing is actually a close port from Ant (It's java based cousin). Phing is written in PHP.

You can use Phing to automate tasks and report results based on those tasks. Drush, on the other hand, just performs tasks. It's unable to determine evaluate the results of the output.

Example use case for phing / drush:

I need drush to dump the database and phing to scp the package from prod to testing.

Phing can store these settings in an external build.properties file and source them into your project. It's able to also store different settings for each environment as well. E.g. Phing can symlink the latest completed that has been dumped by drush to the right document root.

How does all this work?

Phing is driven by an xml. It consumes a build.xml file and takes in attributes (sometimes called targets) and executes simple commands.

More on this:

I highly recommend you review this slideshare by the Phing project leaders:


It'll give you a high level and some concrete usage (plus code) of phing. It's not in any way related to drupal but it'll give you a better idea of how it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.