Jenkins template for continuous integration for Drupal Multi Site

You, Jenkins

We've been working on implementing continuous integration for our projects to improve code quality. In the process we've built a template which should make it easy to setup CI for new projects and want to share these with the community. Hopefully you'll find it useful!.

These are for multi site but you can figure ont how it use it for a single site.



Using the template requires a phing PEAR packages present. They can be installed as follows:

pear channel-discover
pear install phing/phing-2.4.12


Phing (for running Phing build files)


<?xml version="1.0" encoding="utf-8"?>
<!-- creates a clean build,
     symlinks a webdir for each site,
     sets up settings.php,
     symlinks files+settings.php
     for each site (uses multisite to make it work transparently for the devs) -->
<project name="Multisite Project" default="deploy">
    <format property="NOW" pattern="%Y%m%d%H%M%S" />
  <property name="source\_dir" value="./" />
  <property name="build\_destination" value="/opt/jenkins/PROJECTNAME${NOW}" />
  <taskdef name="symlink" classname="phing.tasks.ext.SymlinkTask" />
  <target name="build">
    <!-- copy checkout into our build directory -->
    <copy todir="${build\_destination}">
      <fileset dir="${source\_dir}">
        <exclude name=".git" />
        <exclude name=".git/\*\*" />
        <exclude name="build.xml" />
  <target name="deploy" depends="build">
    <!-- common settings -->
    <!-- <property name="username" value="USERNAME" />  -->
    <property name="web\_dir" value="/var/www/PROJECTNAME" />
    <delete file="${web\_dir}/htdocs" />
    <symlink target="${build\_destination}" link="${web\_dir}/htdocs" />

    <!-- SITE 1 -->
    <property name="username" value="USERNAME" />
    <property name="password" value="PASSWORD" />
    <property name="databasename" value="DBNAME" />
    <copy file="${build\_destination}/sites/default/default.settings.php" tofile="${build\_destination}/sites/SITE1/settings.php">
          <token key="databasename" value="${databasename}" />
          <token key="username" value="${username}" />
          <token key="password" value="${password}" />
    <symlink target="/opt/files/SITE1/files" link="${build\_destination}/sites/SITE1/files" />

    <!-- SITE2 -->
    <property name="username" override="yes" value="USERNAME" />
    <property name="password" override="yes" value="PASSWORD" />
    <property name="databasename" override="yes" value="DBNAME" />
    <copy file="${build\_destination}/sites/default/default.settings.php" tofile="${build\_destination}/sites/SITE2/settings.php">
          <token key="databasename" value="${databasename}" />
          <token key="username" value="${username}" />
          <token key="password" value="${password}" />
    <symlink target="/opt/files/SITE2/files" link="${build\_destination}/sites/SITE2/files" />


default.settings.php - Change the $databases as follow.

 $databases\['default'\]\['default'\] = array(
   'driver' => 'mysql',
   'database' => '@databasename@',
   'username' => '@username@',
   'password' => '@password@',
   'host' => 'localhost',
   'prefix' => '',
© Heshan Wanigasooriya.RSS

🍪 This site does not track you.