Jenkins : Pipeline as Code
Shreyas & Inder
vodQA, Pune 16th March 2019
Shreyas Chaudhari
Quality Analyst at ThoughtWorks, Inc
About Me
Inder Pal Singh
About Me
Quality Analyst at ThoughtWorks, Inc
4
Ground Rules
● Follow the speaker
● Don’t get deviated
● If you are stuck, call any of the volunteers
● We will share all the material with you, don’t bother about that
● Ask questions whenever you have - Don’t wait
● We will focus more on Action than on Philosophy
5
Agenda
● Continuous Integration & Continuous Delivery
● What is Jenkins? Why Jenkins?
● Jenkins Project Types
● Freestyle Project
● Why Pipeline
● Pipeline Concepts
● Pipeline - Structured & Declarative
● Jenkins Job Builder
● Architecture, Automation Framework Architecture & CI Workflow
● References
6
Continuous Delivery
Continuous Integration
● Integrate code into a shared repository frequently
● Each check-in is verified by an automated build
● Can detect errors Early and Easily
Continuous Deployment
● Ability to get changes into production or into the hands of users.
● Code always in deployable state
7
Continuous Integration
● At a minimum:
○ Gather latest source together
○ Compile
○ Execute tests
○ Verify success
● Can include other tasks such as:
○ Rebuild the database
○ Build release distribution
○ Run code analysis and coverage tools
○ Generate documentation
8
Continuous Delivery Vs Continuous Deployment
9
Continuous Integration Servers
10
Jenkins
● Open Source
● Free
● Easily Configurable
● Rich Plugin Ecosystem
● Easy Support
● Fork of Hudson
● Configuration through - GUI and Console Commands
11
Jenkins - Project Types
● Freestyle Project
● Pipeline
● Multibranch Pipeline
12
Maven Phases
Clean
Compile
Package
Install
Test
13
What is Pipeline?
Suite of plugins
Domain Specific
Language
Extensible set of
tools
Text File in SCM
14
Why Pipeline?
Code
Implemented and Checked in SCM
Durable
Survive Jenkins Restarts
Pausable
Can Stop Or Wait For Human Approval
Versatile
Complex CD Requirements
Extensible
Easier to add Plugins in DSL
15
Benefits of Pipeline
Automatically creates
a pipeline
Code review / iteration
on the pipeline
Single source of truth
16
Pipeline Commands
Pipeline
User defined model of CD pipeline
Node
Machine in Jenkins environment
Stage
Conceptually defined subsets of tasks
Steps
Granular task that tells Jenkins what to do
17
Pipeline Types - Scripted Vs Declarative
Scripted Pipeline
● Tremendous amount of Flexibility and Extensibility
● Groovy language has a limited learning curve
● Imperative Programming
Declarative Pipeline
● Simpler and Opinionated syntax
● Limits user with strict and predefined structure
● Declarative Programming
18
Pipeline Concepts - Scripted Vs Declarative
19
20
Jenkins Job Builder
● Configures Jenkins by taking Yaml or Json
● Yaml or Json are human readable
● Create Jenkins job xmls from yamls or jsons
● Uploads to Jenkins using HTTP Api
● Also has Template system
21
How to create Build Pipelines?
JENKINS JOB BUILDER
PIPELINE
CODE TEMPLATES JOBS
APP
TEAM
PET
22
Avoid perils of Shared CI
TOPOLOGY DATA PIPELINE CODE
APP TEAM’S JOBS
23
Product Architecture
24
Automation Pipeline
THANK YOU
For questions or suggestions mailto:
shreyasc@thoughtworks.com
inderpal@thoughtworks.com

Jenkins : Pipeline As Code