Accueil / Blog / Métier / Archives / Drupal and Jenkins: continuous integration howto

Drupal and Jenkins: continuous integration howto

Par Benoit Bryon — publié 07/12/2011, édité le 14/04/2016

Once you know how to run tests with Drupal [1], you'd like some automation...

Here is a recipe to set up a continuous integration service for Drupal, using the well-known Jenkins [2] software.

Prerequisites: system setup

You need:

  • a Jenkins server. Python users may use the jarn.jenkins [3] recipe for buildout;
  • a Drupal 7.x installation;
  • drush.

System setup is not covered by this article.

In the following article, let's say:

  • we got a Jenkins server running at
  • we got a Drupal website running at
  • workspace absolute path is /home/example/
  • Drupal files are installed in www relative to workspace
  • drush installed and in the shell's PATH
  • Jenkins is configured to store log files in var/jenkins/data relative to workspace

Create Drupal tests: example with the predictable_tests module

The creation of Drupal tests is not covered by this article.

You can follow simpletest module documentation [4].

In this article, we are to use the predictable_tests [5] module.

The predictable_tests module registers tests that always or never pass. We will use them to:

  • make sure that our continuous integration service acts as expected;
  • make sure there is no error in our installation. As examples, errors could be related to Drupal or simpletest;
  • try the continuous integration service with "quick" tests. Standards tests bundled with Drupal or simpletest are quite slow to run. So predictable_tests will save us time.

Run Drupal tests with the command line

Follow the how to run tests with Drupal [1] article to get details about running tests with Drupal and examples used in this article.

When you are sure that you can export tests as XML with drush, let's look at Jenkins...

Configure a Jenkins job

  • Go to Jenkins administration interface at

  • Create a new job. Give it a name and choose "free-style" option.

  • Configure the job:

    • For now, we will leave most options blank: let's focus on connecting Jenkins to Drupal. We may improve things later.

    • In the "build" section, click "Add build step" and add a "Execute shell" step with the following code :

      cd $PROJECT_ROOT
      echo $XML_REPORTS_DIR
      mkdir -p $XML_REPORTS_DIR
      bin/drush test-run --uri= --xml=$XML_REPORTS_DIR PredictableUnitTest
    • In "Post-build actions" section, enable "Publish JUnit test result report" and set "Test report XMLs" field to "$BUILD_ID/*.xml".

    • Save.

Run Jenkins job manually

Click the "Build now" link.

In build history, you should see a build progress indicator... When it is done, you can go and see the results. Hope you see "success".


The blue disc means "success". You may enable the "Green balls" plugin to see green markers on success.

Improve Jenkins job

So, we ran some Drupal tests with Jenkins. But we cannot talk about continuous build yet. Here are some steps that we will discuss later:

  • trigger build on some events, such as a cron or a commit on a repository;
  • install, reinstall or upgrade Drupal site during build process;
  • notify build results to development team.

Further readings


[1] (1, 2)
Voir aussi
Retour d'expérience sur la réalisation d'un portail Drupal mélant cartographie et Open Data 15/02/2018

Utilisation de Drupal comme outil centralisateur de flux.

Scraping & Machine Learning : comment fonctionne un moteur de recherche ? Scraping & Machine Learning : comment fonctionne un moteur de recherche ? 22/01/2018

Ou comment utiliser des composants libres pour faire votre mini-Google (ou Qwant)

Drupal 8 pour un site d'université Drupal 8 pour un site d'université 17/01/2018

Pourquoi Drupal 8 est un bon choix pour réaliser un site d'université.

Formation Machine Learning Formation Machine Learning 21/11/2017

Cette formation présente le domaine du Machine Learning, au travers de l'écosystème scientifique ...

Découvrez la formation initiation au Python Scientifique Découvrez la formation initiation au Python Scientifique 24/11/2017

La formation initiation au Python scientifique vous permettra de vous initiez à la programmation ...