Drupal - Are Drush and Phing redundant?

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}" />

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.