Drupal Café
21-11-2012

About Continuous Integration
(and why you should use it)
Introduction

 • Baris Wanschers
 • Co-owner of LimoenGroen
 • Chairman of Stichting Drupal Nederland
Agenda

• The need for Continuous Integration
• How we use it
• Technical overview
• Demo
Show hands

• Who uses version control?
Show hands

• Who uses version control?
• Who uses a DTAP (or DTP)?
Show hands

• Who uses version control?
• Who uses a DTAP (or DTP)?
• Who uses Features / Context?
Show hands

• Who uses version control?
• Who uses a DTAP (or DTP)?
• Who uses Features / Context?
• Who applies Continuous Integration?
We’ve all been there

 • Implementing a new feature? Involves
   putting the site in maintenance for hours
We’ve all been there

 • Implementing a new feature? Involves
   putting the site in maintenance for hours

 • Re-clicking all you’ve done local, on Prod
We’ve all been there

 • Implementing a new feature? Involves
   putting the site in maintenance for hours

 • Re-clicking all you’ve done local, on Prod
 • The client accepts changes on ACC, but
   they still end up different on PROD
We’ve all been there

 • Implementing a new feature? Involves
   putting the site in maintenance for hours

 • Re-clicking all you’ve done local, on Prod
 • The client accepts changes on ACC, but
   they still end up different on PROD

 • In the end: Frustrated Clients
What is it?

"In software engineering, continuous integration (CI)
implements continuous processes of applying quality
control — small pieces of effort, applied frequently.”




                                            Source: Wikipedia
What is it?

"In software engineering, continuous integration (CI)
implements continuous processes of applying quality
control — small pieces of effort, applied frequently.”
“Continuous integration aims to improve the quality of
software, and to reduce the time taken to deliver it, by
replacing the traditional practice of applying quality
control after completing all development."

                                            Source: Wikipedia
What’s the advantage?

 • Direct feedback if it cannot be deployed
   Got e-mail? Back to the drawing board.
What’s the advantage?

 • Direct feedback if it cannot be deployed
   Got e-mail? Back to the drawing board.


 • In control when going live
   Deployed to Test? Then it will work on Production as well.
What’s the advantage?

 • Direct feedback if it cannot be deployed
   Got e-mail? Back to the drawing board.


 • In control when going live
   Deployed to Test? Then it will work on Production as well.


 • Continue developing while CI tool runs
   No need to wait.
What’s the advantage?

 • Direct feedback if it cannot be deployed
   Got e-mail? Back to the drawing board.


 • In control when going live
   Deployed to Test? Then it will work on Production as well.


 • Continue developing while CI tool runs
   No need to wait.


 • Integration with Issue Management
   Update issues by committing your change.
How we use it




    D     T     A   P
How we use it
                Repository
                • develop
                • master




    D     T             A    P
How we use it
                Repository
                • develop
                • master




    D     T             A    P

                                      DB + Files
                             (drush sql-sync / drush rsync)
How we use it
                    Repository
                    • develop
                    • master




        Code       Code          Code




    D          T            A           P

                                                 DB + Files
                                        (drush sql-sync / drush rsync)
How we use it
                            Repository
                            • develop
                            • master
       commit -m
 “Applied X. Fixes #123.”

         develop or
        master/[TAG]




       D               T            A    P
How we use it
                            Repository
                            • develop    Service hooks
                            • master
       commit -m
 “Applied X. Fixes #123.”

         develop or
        master/[TAG]




       D               T            A           P
How we use it
                                  Repository
                                  • develop    Service hooks
                                  • master
       commit -m
 “Applied X. Fixes #123.”

         develop or
        master/[TAG]    develop




       D               T                  A           P
How we use it
                                  Repository
                                  • develop    Service hooks
                                  • master
       commit -m
 “Applied X. Fixes #123.”                                      manual start

         develop or
        master/[TAG]    develop




       D               T                  A           P
How we use it
                                  Repository
                                  • develop      Service hooks
                                  • master
       commit -m
 “Applied X. Fixes #123.”                                        manual start

         develop or
        master/[TAG]    develop    develop




       D               T                     A          P
How we use it
                                  Repository
                                  • develop      Service hooks
                                  • master
       commit -m
 “Applied X. Fixes #123.”                                        manual start

         develop or
        master/[TAG]    develop    develop       master/[TAG]




       D               T                     A            P
How we use it
                                  Repository
                                  • develop      Service hooks
                                  • master
       commit -m
 “Applied X. Fixes #123.”                                        manual start

         develop or
        master/[TAG]    develop    develop       master/[TAG]




       D               T                     A            P
Technical set-up
DEV environment           Jenkins                               Git
• LAMP                    • Tomcat                              • GitHub/BitBucket
• Git                     • Apache (as proxy for Tomcat)        • Service Hooks
• Git flow                 • Jenkins plugins:                    • Service user (read
• Drush                       • Git                             only) + ssh key
• Drush alias files            • Github
                              • Git parameter
                          • Jenkins jobs per project / target   Redmine
                          environment                           • LAMP
Target envs (T/A/P)
                          • Shell scripts:                      • Redmine plugin:
• LAMP
                              • make-backup.sh                      • Github webhook
• Drush
                              • update-code.sh
• SSH key Jenkins user
                              • apply-updates.sh
in site user authorized
keys
Demo

• Issue in Redmine
  ”Replace latest blogs in footer with single teaser”
Demo

• Issue in Redmine
  ”Replace latest blogs in footer with single teaser”


• Fix on dev & Update Feature
Demo

• Issue in Redmine
  ”Replace latest blogs in footer with single teaser”


• Fix on dev & Update Feature
• Commit with Issue number
Demo

• Issue in Redmine
  ”Replace latest blogs in footer with single teaser”


• Fix on dev & Update Feature
• Commit with Issue number
• Champagne!
Future improvements

• Features does not work on all modules
• Automated tests with Jenkins
  SimpleTest / Behat / Selennium


• Automated roll-back on errors
• Set monitoring to ‘scheduled downtime’ on
  deployments
Questions?

• baris@limoengroen.nl
• www.limoengroen.nl
  www.bariswanschers.com

• @BarisW on Drupal.org / IRC / Twitter

Continuous Integration & Drupal

  • 1.
    Drupal Café 21-11-2012 About ContinuousIntegration (and why you should use it)
  • 2.
    Introduction • BarisWanschers • Co-owner of LimoenGroen • Chairman of Stichting Drupal Nederland
  • 3.
    Agenda • The needfor Continuous Integration • How we use it • Technical overview • Demo
  • 4.
    Show hands • Whouses version control?
  • 5.
    Show hands • Whouses version control? • Who uses a DTAP (or DTP)?
  • 6.
    Show hands • Whouses version control? • Who uses a DTAP (or DTP)? • Who uses Features / Context?
  • 7.
    Show hands • Whouses version control? • Who uses a DTAP (or DTP)? • Who uses Features / Context? • Who applies Continuous Integration?
  • 8.
    We’ve all beenthere • Implementing a new feature? Involves putting the site in maintenance for hours
  • 9.
    We’ve all beenthere • Implementing a new feature? Involves putting the site in maintenance for hours • Re-clicking all you’ve done local, on Prod
  • 10.
    We’ve all beenthere • Implementing a new feature? Involves putting the site in maintenance for hours • Re-clicking all you’ve done local, on Prod • The client accepts changes on ACC, but they still end up different on PROD
  • 11.
    We’ve all beenthere • Implementing a new feature? Involves putting the site in maintenance for hours • Re-clicking all you’ve done local, on Prod • The client accepts changes on ACC, but they still end up different on PROD • In the end: Frustrated Clients
  • 12.
    What is it? "Insoftware engineering, continuous integration (CI) implements continuous processes of applying quality control — small pieces of effort, applied frequently.” Source: Wikipedia
  • 13.
    What is it? "Insoftware engineering, continuous integration (CI) implements continuous processes of applying quality control — small pieces of effort, applied frequently.” “Continuous integration aims to improve the quality of software, and to reduce the time taken to deliver it, by replacing the traditional practice of applying quality control after completing all development." Source: Wikipedia
  • 14.
    What’s the advantage? • Direct feedback if it cannot be deployed Got e-mail? Back to the drawing board.
  • 15.
    What’s the advantage? • Direct feedback if it cannot be deployed Got e-mail? Back to the drawing board. • In control when going live Deployed to Test? Then it will work on Production as well.
  • 16.
    What’s the advantage? • Direct feedback if it cannot be deployed Got e-mail? Back to the drawing board. • In control when going live Deployed to Test? Then it will work on Production as well. • Continue developing while CI tool runs No need to wait.
  • 17.
    What’s the advantage? • Direct feedback if it cannot be deployed Got e-mail? Back to the drawing board. • In control when going live Deployed to Test? Then it will work on Production as well. • Continue developing while CI tool runs No need to wait. • Integration with Issue Management Update issues by committing your change.
  • 18.
    How we useit D T A P
  • 19.
    How we useit Repository • develop • master D T A P
  • 20.
    How we useit Repository • develop • master D T A P DB + Files (drush sql-sync / drush rsync)
  • 21.
    How we useit Repository • develop • master Code Code Code D T A P DB + Files (drush sql-sync / drush rsync)
  • 22.
    How we useit Repository • develop • master commit -m “Applied X. Fixes #123.” develop or master/[TAG] D T A P
  • 23.
    How we useit Repository • develop Service hooks • master commit -m “Applied X. Fixes #123.” develop or master/[TAG] D T A P
  • 24.
    How we useit Repository • develop Service hooks • master commit -m “Applied X. Fixes #123.” develop or master/[TAG] develop D T A P
  • 25.
    How we useit Repository • develop Service hooks • master commit -m “Applied X. Fixes #123.” manual start develop or master/[TAG] develop D T A P
  • 26.
    How we useit Repository • develop Service hooks • master commit -m “Applied X. Fixes #123.” manual start develop or master/[TAG] develop develop D T A P
  • 27.
    How we useit Repository • develop Service hooks • master commit -m “Applied X. Fixes #123.” manual start develop or master/[TAG] develop develop master/[TAG] D T A P
  • 28.
    How we useit Repository • develop Service hooks • master commit -m “Applied X. Fixes #123.” manual start develop or master/[TAG] develop develop master/[TAG] D T A P
  • 29.
    Technical set-up DEV environment Jenkins Git • LAMP • Tomcat • GitHub/BitBucket • Git • Apache (as proxy for Tomcat) • Service Hooks • Git flow • Jenkins plugins: • Service user (read • Drush • Git only) + ssh key • Drush alias files • Github • Git parameter • Jenkins jobs per project / target Redmine environment • LAMP Target envs (T/A/P) • Shell scripts: • Redmine plugin: • LAMP • make-backup.sh • Github webhook • Drush • update-code.sh • SSH key Jenkins user • apply-updates.sh in site user authorized keys
  • 30.
    Demo • Issue inRedmine ”Replace latest blogs in footer with single teaser”
  • 31.
    Demo • Issue inRedmine ”Replace latest blogs in footer with single teaser” • Fix on dev & Update Feature
  • 32.
    Demo • Issue inRedmine ”Replace latest blogs in footer with single teaser” • Fix on dev & Update Feature • Commit with Issue number
  • 33.
    Demo • Issue inRedmine ”Replace latest blogs in footer with single teaser” • Fix on dev & Update Feature • Commit with Issue number • Champagne!
  • 34.
    Future improvements • Featuresdoes not work on all modules • Automated tests with Jenkins SimpleTest / Behat / Selennium • Automated roll-back on errors • Set monitoring to ‘scheduled downtime’ on deployments
  • 35.
    Questions? • baris@limoengroen.nl • www.limoengroen.nl www.bariswanschers.com • @BarisW on Drupal.org / IRC / Twitter

Editor's Notes

  • #2 Welcome all, thanks for attending. And thank you Michel for having me here. We gave this talk at the latest Tech Talk @ Triquanta and due to the great feedback we decided to do it again.\n
  • #3 LimoenGroen has a mission to create durable websites and a better web. We use Open Source (Drupal), and we make sure they are future-proof and accessible by anyone.\n
  • #4 AGENDA\nNEXT: Show hands. \n
  • #5 Surprisingly to see that nearly no-one already applies CI and we saw the same at the Tech Talk. And there is a need, because... NEXT\n
  • #6 Surprisingly to see that nearly no-one already applies CI and we saw the same at the Tech Talk. And there is a need, because... NEXT\n
  • #7 Surprisingly to see that nearly no-one already applies CI and we saw the same at the Tech Talk. And there is a need, because... NEXT\n
  • #8 Surprisingly to see that nearly no-one already applies CI and we saw the same at the Tech Talk. And there is a need, because... NEXT\n
  • #9 Companies that write down all clicks (content types, views, etc) and re-apply these manually on Acceptance and Production. Companies that export a view and import it on Prod.\n
  • #10 Companies that write down all clicks (content types, views, etc) and re-apply these manually on Acceptance and Production. Companies that export a view and import it on Prod.\n
  • #11 Companies that write down all clicks (content types, views, etc) and re-apply these manually on Acceptance and Production. Companies that export a view and import it on Prod.\n
  • #12 Companies that write down all clicks (content types, views, etc) and re-apply these manually on Acceptance and Production. Companies that export a view and import it on Prod.\n
  • #13 \n
  • #14 \n
  • #15 Not everything can be integrated with Features module. Then we use hook_update_N() scripts. \n
  • #16 Not everything can be integrated with Features module. Then we use hook_update_N() scripts. \n
  • #17 Not everything can be integrated with Features module. Then we use hook_update_N() scripts. \n
  • #18 Not everything can be integrated with Features module. Then we use hook_update_N() scripts. \n
  • #19 \n
  • #20 \n
  • #21 \n
  • #22 \n
  • #23 \n
  • #24 \n
  • #25 \n
  • #26 \n
  • #27 \n
  • #28 \n
  • #29 \n
  • #30 \n
  • #31 \n
  • #32 Eerst git pull, dan build steps.\n
  • #33 \n
  • #34 \n
  • #35 \n
  • #36 \n
  • #37 \n
  • #38 \n