Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Brujug Jenkins pipeline scalability

2,212 views

Published on

http://www.meetup.com/BruJUG/events/228994900/

During this session, you will presented a solution to the problem of scalability of continuous delivery in Jenkins, when your organisation has to deal with thousands of jobs, by introducing a self-service approach based on the "pipeline as code" principles.

Published in: Engineering

Brujug Jenkins pipeline scalability

  1. 1. JOB SCALABILITY IN JENKINS GETTING OUT OF THE JOB JUNGLE BruJUG - March 9th, 2016 - @DamienCoraboeuf
  2. 2. WHO AM I? ▸ Damien Coraboeuf (@DamienCoraboeuf) ▸ Born to Java in 1996 ▸ “Brol” engineer since 2008 ▸ Automating pipelines @ Clear2Pay / FIS & Multipharma I’ll be your guide on this journey
  3. 3. THE MAP Short introduction to Jenkins Birth of a pipeline Manual mode The Job DSL Branching and its consequences Pipeline as code Pipeline as not code Automation of automation We want to get there Look, there is another
 beach here! Do not go there! 💀
  4. 4. DO YOU KNOW WHO THIS IS?
  5. 5. JENKINS ▸ http://jenkins-ci.org/ ▸ Very versatile Continuous Integration engine ▸ ~ 70% of the CI market (2012 figures) ▸ Open source - strong community ▸ Extensible ▸ more than 1000 plugins ▸ easy to develop new ones ▸ Job scheduler ▸ Integrates with basically everything
  6. 6. JENKINS - JOBS & FOLDERS
  7. 7. JENKINS - JOBS IN FOLDER
  8. 8. JENKINS - PIPELINE VIEWS
  9. 9. JENKINS - JOB
  10. 10. JENKINS - JOB CONFIGURATION Let’s get some sources…
  11. 11. JENKINS - JOB CONFIGURATION Let’s run some Bash…
  12. 12. JENKINS - JOB CONFIGURATION Let’s launch some Gradle…
  13. 13. JENKINS - JOB CONFIGURATION Let’s trigger another job…
  14. 14. PIPELINES ▸ Defining jobs ▸ Linking them together ▸ Running them in parallel or in sequence ▸ Some triggers are automatic, other ones are manual BUILD DEPLOY ENV 1 DEPLOY ENV 2 DEPLOY ENV 3 PUBLICATION RELEASE
  15. 15. A PIPELINE IS BORN BUILD DEPLOY ENV 1 DEPLOY ENV 2 DEPLOY ENV 3 PUBLICATION RELEASE BUILD DEPLOY ENV 1 DEPLOY ENV 2 DEPLOY ENV 3 PUBLICATION RELEASE BUILD DEPLOY ENV 1 DEPLOY ENV 2 DEPLOY ENV 3 PUBLICATION RELEASE Commit 1 Commit 2 Commit 3
  16. 16. SO FAR SO GOOD “Look Ma, I’ve built a pipeline!” “Lovely. Now, build one for your sister.”
  17. 17. THE STORY ▸ 40+ projects… ▸ …several maintenance & feature branches per project ▸ … complex validation pipelines (10 - 20 jobs) ▸ … thousands of jobs ▸ … only a small team for Jenkins Jenkins team > 2700 jobs and growing…
  18. 18. In order to scale, we want: ✔ Self service ✔ Security ✔ Simplicity ✔ Extensibility
  19. 19. “What are we?” “Developers!” “What do we do?” “Code!” “Why do we do it?” “Automation!”
  20. 20. PIPELINE AS CODE ▸ The Job DSL ▸ Pipeline as code ▸ Pipeline libraries ▸ Pipeline as properties ▸ Pipeline automation
  21. 21. JOB DSL PLUGIN - START OF THE JOURNEY OUT OF THE JUNGLE ▸ Define a job using a Groovy based DSL!
  22. 22. JOB DSL PLUGIN ▸ Very well supported ▸ Very good documentation ▸ Supports most of the plugins ▸ Built-in extensibility: inline or DSL extensions
  23. 23. JOB DSL PLUGIN ▸ Folders & views ▸ … automatic triggers upon generation ▸ … using files in workspace
  24. 24. JOB DSL PLUG-IN ▸ This remains code…
  25. 25. JOB DSL PLUGIN ▸ DSL based generation done from a job ▸ Can generate and/or update other jobs ▸ Can even run while jobs are running :) SEED JOB GENERATED JOB(S) DSL SCRIPT Generates Accesses (SCM or inline) GENERATED JOB(S) GENERATED JOB(S)
  26. 26. BRANCHING ▸ One Seed DSL job is all very good but… ▸ Pipeline evolves with the code ▸ Different pipelines for different branches develop release/2.0 Needs a new job Pipelines for releases
 might be more complex
  27. 27. PIPELINE AS CODE ▸ Your pipeline is linked to the code it builds ▸ Define your pipeline in your code Project src pom.xml job-dsl-script.groovy
  28. 28. PIPELINE CODE DUPLICATION ▸ We can now generate a pipeline for any branch, any commit
 
 
 
 ▸ It evolves with your branches and is merged like any other piece of code ▸ That’s good enough for 1 project ▸ With several (many) projects, the level of DSL code duplication explodes! DEVELOP FEATURE/BIG RELEASE/1.0 DSL SCRIPT DSL SCRIPT DSL SCRIPT DEVELOP FEATURE/BIG RELEASE/1.0 DSL SCRIPT DSL SCRIPT DSL SCRIPT DEVELOP FEATURE/BIG RELEASE/1.0 DSL SCRIPT DSL SCRIPT DSL SCRIPT DEVELOP FEATURE/BIG RELEASE/1.0 DSL SCRIPT DSL SCRIPT DSL SCRIPT DEVELOP FEATURE/BIG RELEASE/1.0 DSL SCRIPT DSL SCRIPT DSL SCRIPT
  29. 29. PIPELINE CODE DUPLICATION ▸ Job DSL code duplication has the same issues than production code duplication DEVELOP FEATURE/BIG RELEASE/1.0 DSL SCRIPT DSL SCRIPT DSL SCRIPT DEVELOP FEATURE/BIG RELEASE/1.0 DSL SCRIPT DSL SCRIPT DSL SCRIPT DEVELOP FEATURE/BIG RELEASE/1.0 DSL SCRIPT DSL SCRIPT DSL SCRIPT DEVELOP FEATURE/BIG RELEASE/1.0 DSL SCRIPT DSL SCRIPT DSL SCRIPT ✘ ✘ ✘ ✘ ✘ ✘ ✘✘✘✘✘✘ DEVELOP FEATURE/BIG RELEASE/1.0 DSL SCRIPT DSL SCRIPT DSL SCRIPT DEVELOP FEATURE/BIG RELEASE/1.0 DSL SCRIPT DSL SCRIPT DSL SCRIPT ✘✘✘✘✘✘ DEVELOP FEATURE/BIG RELEASE/1.0 DSL SCRIPT DSL SCRIPT DSL SCRIPT DEVELOP FEATURE/BIG RELEASE/1.0 DSL SCRIPT DSL SCRIPT DSL SCRIPT ✘✘✘✘✘✘ DEVELOP DSL SCRIPT DEVELOP DSL SCRIPT ✘ ✘ DEVELOP DSL SCRIPT ✘ DEVELOP DSL SCRIPT ✘ LEASE/1.0 L SCRIPT LEASE/1.0 L SCRIPT LEASE/1.0 L SCRIPT LEASE/1.0 L SCRIPT DEVELOP FEATURE/BIG RELEASE/1.0 DEVELOP FEATURE/BIG RELEASE/1.0 DEVELOPLEASE/1.0
  30. 30. PIPELINE LIBRARIES TO THE RESCUE ▸ Pipeline is code ▸ Reuse of code through versioned libraries DEVELOP FEATURE/BIG RELEASE/1.0 DSL SCRIPT DSL SCRIPT DSL SCRIPT PIPELINE DSL LIBRARY 1.1 1.0 Normal project
 Can be tested
 Can be released
  31. 31. PIPELINE LIBRARIES TO THE RESCUE ▸ DSL libraries as code libraries DEVELOP FEATURE/BIG RELEASE/1.0 DSL SCRIPT DSL SCRIPT DSL SCRIPT PIPELINE DSL LIBRARY 1.1 1.0 COMMON DSL LIBRARY 1.0 Dependencies
  32. 32. ARE WE DONE? ▸ We can describe a pipeline using a DSL ▸ The pipeline is defined together with the code it builds ▸ The DSL can use libraries to reduce code duplication ?
  33. 33. NOT QUITE… ▸ This is not enough to really scale ▸ We still have to write some DSL ▸ Self service ✔ ▸ Security ✘ ▸ Simplicity ✘ ▸ Extensibility ✔
  34. 34. PIPELINE AS… PROPERTIES ▸ Let’s describe the pipeline using a properties file ▸ Which pipeline library & which version ▸ Configuration properties - specific to the library ▸ Property file format ubiquitous ▸ No code running on the master ▸ Can be used for reporting on all the pipelines!
  35. 35. PIPELINE AS PROPERTIES seed.properties
  36. 36. SEED PLUGIN ▸ https://github.com/jenkinsci/seed-plugin ▸ Allows to generate: ▸ projects folders ▸ branches pipelines ▸ based on seed files (properties and/or DSL) ▸ integration with hooks
  37. 37. SEVERAL INTEGRATION MODES SEED.PROPERTIES SEED PLUGIN SEED.PROPERTIES SEED.GROOVYSEED.GROOVY PIPELINE LIBRARY PIPELINE LIBRARY BRANCH PIPELINE 95% 4% 1%
  38. 38. GENERATION STRUCTURE SEED PROJECT GENERATOR PROJECT FOLDER BOOTSTRAPPING BRANCH GENERATOR BRANCH FOLDER BRANCH JOB 1 BRANCH JOB 2 BRANCH JOB 3 BRANCH JOB 4 GENERATION Project teamJenkins team Project only visible by project team
  39. 39. SEED JOBS BOOTSTRAPPING GENERATION GENERATION
  40. 40. AUTOMATION
  41. 41. HOOKS ▸ Generations can be automated using hooks at SCM level ▸ Support for GitHub, BitBucket, generic HTTP calls (for SVN) ▸ Configurable. For example: BRANCH CREATION SCM EVENT Seed plug-in COMMIT SEED CHANGED BRANCH DELETION PIPELINE EVENT Generation Triggers the pipeline Regenerates the pipeline Deletes the pipeline
  42. 42. RESPONSIBILITIES Jenkins team Pipeline libraries Develops and maintains Development team seed.properties Defines Seed plug-in SCM Triggers
  43. 43. WHAT DID WE JUST ACHIEVE? ▸ Automation of automation ▸ Self service ✔ ▸ Pipeline automation from SCM ▸ Security ✔ ▸ Project level authorisations ▸ No code on the master ▸ Simplicity ✔ ▸ Property files ▸ Extensibility ✔ ▸ Pipeline libraries ▸ Direct job DSL still possible
  44. 44. YOU CAN NOW RELAX…
  45. 45. DEMO TIME ▸ Bootstrapping a project ▸ Configuring the project for GitHub ▸ Creating a branch —> Branch folder generated ▸ Committing on the branch —> Pipeline started ▸ Updating the pipeline branch —> Pipeline regenerated ▸ Deleting the branch —> Branch folder gone
  46. 46. DEMO - PIPELINE AS CODE seed/seed.groovy
  47. 47. DEMO - GITHUB SETUP
  48. 48. DEMO - JENKINS SETUP
  49. 49. DEMO - BOOTSTRAPPING
  50. 50. A GLIMPSE OF THE FUTURE ▸ Jenkins 2.0 ▸ Pipeline plug-in ▸ “Pipeline as Code” in the core ▸ How does the current solution fit?
  51. 51. SEED & PIPELINE PLUGIN ▸ The Seed plugin will keep working ▸ It can already generate pipeline jobs (Job DSL) ▸ But overlap of functionalities Branch pipelines Pipeline as code SEED PIPELINE Hook integration Pipeline as properties Community & support Pipeline libraries Pipeline script library
  52. 52. SEED IN PIPELINE PLUGIN ▸ The Seed plugin as extension of the Pipeline plugin Branch pipelines Pipeline as code SEED PIPELINE Hook integrationPipeline as properties Community & support Pipeline libraries Pipeline script library
  53. 53. THANKS YOU! Thanks to: ‣ BruJUG ‣ Olivier Hubaut ‣ ESI Contact: ▸ http://nemerosa.com ▸ @DamienCoraboeuf

×