Drupal Developer0.8Minimum Jenkins requirement: 1.580ID: drupal-developer
A plugin to review code and run tests on Drupal.
- Install drush 7+ globally or configure the path to Drush on
- Install Checkstyle, JUnit and PHP Built-in Web Server
- Create a local database:
CREATE DATABASE db;
- Create a Freestyle project that looks like this, or create a Drupal project
- Under 'Build a Drupal instance', update the database URL
1. Create Local Database
CREATE DATABASE db;
2. Install drush 7+
git checkout tags/7.0.0-rc2
php composer.phar install
- Go to
- Under 'Drush installations', set 'Path to Drush home' to
3. Create project
Create a new 'Freestyle' project.
Alternatively you may create a 'Drupal' project which generates a ready-to-use job to review code and run tests on a vanilla Drupal core. If you use this option then you may skip most of the instrutions below: just update the database URL and possibly set up a web server.
4. Configure Source Code Management
Configure the Source Code Management section to fetch a full Drupal code base. Here are a few options:
- If you just want to run tests on a Drupal core, you may use Git:
- Branch Specifier:
- If your own code repository includes a Drupal core, then just pull it
- If it does not, then you may combine your own repo with the drupal.org repo using Multiple SCMs
- Alternatively you may use a Drush Makefile source
By default Jenkins pulls code into the workspace root but you might want to put Drupal into a subdirectory to keep things clean (e.g.
- If using Git: set option 'Additional Behaviours / Check out to a sub-directory' to
- If using Subversion: set option 'Local module directory' to
- If using a Drush Makefile: set option 'Drupal root directory' to
Note that a Drush Makefile source will fetch the code every time a new build runs. Using a regular source like Git or Subversion is probably more efficient.
Also only Drupal 7 code is supported.
5. Configure Local Web Server
Some tests fail if Drupal does not run behind a web server. Here are a couple of solutions:
- Either install PHP Built-in Web Server (requires PHP >= 5.4.0) e.g.:
- Document root:
drupal(or leave empty if the Drupal root is the workspace root)
- Or install Apache locally and make it point at the Drupal root (e.g.
6. Configure Builds
Add build steps:
- 'Build a Drupal instance'
- 'Review code on Drupal'
- 'Run tests on Drupal'
The default values should work though you need to update a few things:
- Update the database URL in step 'Build a Drupal instance' to point at your database
- If you have checked out Drupal into a subdirectory (e.g.
drupal) then update the Drupal root directory of every step accordingly ; otherwise, just leave it empty
- The URI of step Run tests on Drupal should match what you have configured on your webserver (e.g.
Note that if your code base does not include a copy of the Coder module, then step Review code on Drupal will automatically download it into
7. Plot results
Plot Code Review results using Checkstyle:
- Create a post-build action 'Publish Checkstyle analysis results'
- If the logs directory for the code review is
logs_codereviewthen set 'Checkstyle results' to
- You might want to set the unstable threshold to 0 normal warning, and the failed threshold to 0 high warning
Plot Test results using JUnit:
- Create a post-build action 'Publish JUnit test result report'
- If the logs directory for the tests is
logs_teststhen set 'Test report XMLs' to
8. Build the Project
- Click on 'Build Now': Jenkins should start reviewing and testing the code base
- After a few builds complete, trend graphs should show up
- drush 7+
- SCM API
- Checkstyle, JUnit and PHP Built-in Web Server (or Apache) are not required but are relevant
0.8 (release 2016-08-12)
- JENKINS-35544 Fix NPE when module has no version.
0.6 (release 2015-09-05)
- Initial release