30

I hear the buzz words, "continuous integration", "drush" and "jenkins" often. Thus, sparking my interest.

How are drush and jenkins used together for continuous integration?

Also, why would you want to use drush and jenkins together?

2 Answers 2

20

For my projects, I use a build script made of Drush commands in a Jenkins job. I use my Phing Drush Task project to run Drush from a Phing build script. This allow me to leverage the existing Phing tasks (eg. files copy, phplint, etc.). With the help of Drush, this build script

  • Downloads all non-custom code (ie. Drupal core and contribs module and themes) with Drush Make to ./dist
  • Expands placeholders in a versioned settings.php (ie. replace ${db_host} with the actual DB hostname) while copying it to the freshly downloaded ./dist/sites/default folder.
  • Copy custom modules and themes to ./dist/sites/all/modules/custom and ./dist/sites/all/themes/custom
  • Run phplint for all files from my custom modules and themes.
  • Copy everything under ./dist to a pre-configured webroot.
  • Run drush site-install testing and drush pm-enable simpletest to install a fresh site using the build code base and able to run SimpleTest.
  • Run drush test-run to run my custom module test suites.
  • Run drush coder-review.

Here is a commented build.xml template for Drush usage in Jenkins.

2
  • Does that mean your CI environement is on the same machine than your php server ? I don't understand how you manage to copy your own sources in sites/all/modules/custom (for instance). This is probably because I don't know how work drush ... but nowhere I see equivalent of scp / ftp task from your CI Plateform to Php one. Commented Nov 13, 2012 at 10:22
  • 1
    Yes the CI server and the webserver serving the test site are on the same machine. Off course you could also copy the file from the CI workspace to the webserver host. The rsync command of Drush could be used for this. Then Drush can be used to run command on the machine hosting the webserver. Commented Nov 13, 2012 at 19:52
3

You can use Phing in Jenkins, so you can use Drush through http://drupal.org/project/phingdrushtask (Pierre Buyle on SE.COM)

Custom example:

 <drush command='cc' root="${project.drupal.core.dir}" uri="${env.host.name}" assume="yes">
  <param>all</param>
</drush>
0

Your Answer

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

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