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.
1. JOB SCALABILITY IN JENKINS
GETTING OUT OF THE JOB JUNGLE
BruJUG - March 9th, 2016 - @DamienCoraboeuf
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. 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!
💀
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
12. JENKINS - JOB CONFIGURATION
Let’s launch some Gradle…
13. JENKINS - JOB CONFIGURATION
Let’s trigger another job…
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
16. SO FAR SO GOOD
“Look Ma, I’ve built a pipeline!”
“Lovely. Now, build one for your sister.”
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.
19. In order to scale, we want:
✔ Self service
✔ Security
✔ Simplicity
✔ Extensibility
26. 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)
27. 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
28. 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
29. 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
32. 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
33. 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
34. 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
?
35. NOT QUITE…
▸ This is not enough to really scale
▸ We still have to write some DSL
▸ Self service ✔
▸ Security ✘
▸ Simplicity ✘
▸ Extensibility ✔
36. 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!
43. 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
45. 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
47. 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
52. A GLIMPSE OF THE FUTURE
▸ Jenkins 2.0
▸ Pipeline plug-in
▸ “Pipeline as Code” in the core
▸ How does the current solution fit?
53. 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
54. 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
55. THANKS YOU!
Thanks to:
‣ BruJUG
‣ Olivier Hubaut
‣ ESI
Contact:
▸ http://nemerosa.com
▸ @DamienCoraboeuf