SlideShare a Scribd company logo
Pipeline as code
Building Continuous Delivery Pipelines with Jenkins 2.0
Bert	Jan	Schrijver
@bjschrijverbertjan@jpoint.nl
@bjschrijver
Let’s meet
Bert Jan Schrijver
@bjschrijver
Outline
• Definitions
• Jenkins 1.x
• What’s new in Jenkins 2.0?
• Pipeline as code
• Pipelines in depth
• Jenkins 2.0 in the wild
Thanks to @alexsotob
and @kohsukekawa!
@bjschrijver
Definitions
Every	change	goes	through	the	
build/test	pipeline	and	
automatically	gets	put	into	
production.
Continuous Deployment
An	automated	sequence	of	stages	
to	deliver	software	from	version	
control	to	your	users.
Pipeline
Building	and	testing	software	in	
such	a	way	that	the	software	can	be	
released	to	production	at	any	time.	
Continuous Delivery
Team	members	integrate	their	work	
frequently.	Commits	are	verified	by	
automated	builds	and	tests.
Continuous Integration
Who’s	who	in	CI	&	CD
@bjschrijver
About Jenkins
• De-facto standard tool for automation in software
development and beyond
• Around for 10+ years, millions of users
• Over 100.000 active installations
• Jenkins is mission critical for >90% of its users
• Version 2.0: first major release in years
@bjschrijver
Jenkins: an overview
Source: http://www.slideshare.net/asotobu/jenkins-20-65705621
@bjschrijver
DEMO
@bjschrijver
What’s new in Jenkins 2?
• Better out-of-the-box experience
• Default set of plugins
• Secured by default
• Revamped UI
• Pipeline as code
• In general: more code, less GUI, less state
• Drop-in upgrade, backwards compatible w/1.6
@bjschrijver
Pipeline as code
• Key new feature
• Positions Jenkins for:
• continuous delivery use cases
• other more complex automations of today
• Allows to:
• describe chain of automation in textual form

and put it in version control
@bjschrijver
Pipeline as code
• Grows with you from simple to complex
• Handle lots of jobs without repetition
• Survives Jenkins restarts
• Brings next level of reuse to Jenkins
@bjschrijver
My first pipeline
node('java8') {



stage('Configure') {

env.PATH = "${tool 'maven-3.3.9'}/bin:${env.PATH}"

} 



stage('Checkout') {

git 'https://github.com/bertjan/spring-boot-sample'

} 



stage('Build') {

sh 'mvn -B -V -U -e clean package' 

} 



stage('Archive') {

junit allowEmptyResults: true, testResults: '**/target/**/TEST*.xml'

} 



}
@bjschrijver
DEMO
@bjschrijver
Pipeline syntax
• Built-in syntax and snippet generator
• Pipeline reference:

https://jenkins.io/doc/pipeline/steps
• Plugin documentation
• If all else fails: dive into the source
@bjschrijver
SNIPPETS
@bjschrijver
Archive build artifacts
archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
@bjschrijver
Cleanup old builds
properties(

[buildDiscarder(logRotator(

artifactDaysToKeepStr: '', 

artifactNumToKeepStr: '', 

daysToKeepStr: '', 

numToKeepStr: '10'))

])
@bjschrijver
E-mail notification
try {



// build steps here



} catch (e) {

currentBuild.result = "FAILED"

def subject = 'Build '' + env.JOB_NAME + '' (branch '' + branch + '') ' +

'failed in Jenkins'

def body = 'Build log is attached. Details: ' + env.BUILD_URL

def to = 'email@domain.com'

mail to: to, subject: subject, body: body, attachLog: true

throw e

}



@bjschrijver
Including files, using constants
// File common/Constants.groovy:
class Constants {

static final MAJOR_VERSION_NUMBER = '3.2.1';



static final SONAR_URL = 'https://sonar.my.company.com';

}



return this;

// Jenkinsfile:
load 'common/Constants.groovy'

sh "mvn -B -V -U -e sonar:sonar -Dsonar.host.url='${Constants.SONAR_URL}'"
@bjschrijver
Re-usable workflow steps
// In repo ssh://<username>@<jenkins-url>:2222/workflowLibs.git,
// file my.company.package.MyWorkflowSteps
package my.company.package





def someBuildStep() {

// Some build step

}



// In Jenkinsfile:
def mySteps = new my.company.package.MyWorkflowSteps()

mySteps.someBuildStep()

@bjschrijver
Parallel run on multiple nodes
stage('Checkout') {

git 'https://github.com/bertjan/spring-boot-sample'

stash excludes: 'build/', includes: '**', name: 'source'

} 



stage ('Test') {

parallel 'unit': {

node {

// perform unit test

unstash 'source'

sh 'mvn test'

junit '**/build/test-results/*.xml'

}

}, 'integration': {

node {

// perform integration test

unstash 'source'

sh 'mvn integration-test'

junit '**/build/test-results/*.xml'

}

}

}
@bjschrijver
DEMO
@bjschrijver
Jenkins 2.0 in the wild
• Upgraded a 1.6 instance with about 50 builds
• Replaced all builds with pipelines
• Minimal use of Jenkins workflow internal repo
• One single Git repo for all builds
• Re-usable pipelines and steps
• Builds are far more consistent
@bjschrijver
Jenkins 2.0: Moving forward
• Upcoming changes: focused on ease of use
• simplified pipeline model
• look less like programming, more declarative
• cater both point-and-click and editor people
• fails when Jenkins reads it, not when it runs it
@bjschrijver
SUMMARY
@bjschrijver
Summary
• Jenkins 2.0: powerful continuous delivery platform
• UI improvements, more curated experience
• Pipeline as code: less clicks, more code
• Sample code:
• https://github.com/bertjan/spring-boot-sample
@bjschrijver@bjschrijver
Questions?Questions?
@bjschrijver@bjschrijver
Thanks for your time!
Got feedback? Tweet it!
Please rate this session!

More Related Content

ODP
Pipeline based deployments on Jenkins
PPTX
Pipeline as code - new feature in Jenkins 2
PDF
Jenkins Pipelines
PDF
7 Habits of Highly Effective Jenkins Users
PDF
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
PPTX
Jenkins days workshop pipelines - Eric Long
PDF
(Declarative) Jenkins Pipelines
PDF
Building an Extensible, Resumable DSL on Top of Apache Groovy
Pipeline based deployments on Jenkins
Pipeline as code - new feature in Jenkins 2
Jenkins Pipelines
7 Habits of Highly Effective Jenkins Users
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
Jenkins days workshop pipelines - Eric Long
(Declarative) Jenkins Pipelines
Building an Extensible, Resumable DSL on Top of Apache Groovy

What's hot (20)

PPTX
Jenkins, pipeline and docker
PPTX
7 Habits of Highly Effective Jenkins Users
PDF
Codifying the Build and Release Process with a Jenkins Pipeline Shared Library
PDF
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
PDF
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
PPTX
Continuous Delivery - Pipeline as-code
PDF
Brujug Jenkins pipeline scalability
PPTX
CI/CD on Android project via Jenkins Pipeline
PDF
Let's go HTTPS-only! - More Than Buying a Certificate
PDF
Voxxed Luxembourd 2016 Jenkins 2.0 et Pipeline as code
PDF
sed.pdf
PDF
Jenkins vs. AWS CodePipeline (AWS User Group Berlin)
PPTX
Jenkins pipeline as code
PDF
OSDC 2017 - Julien Pivotto - Automating Jenkins
PDF
Monitoring Akka with Kamon 1.0
PDF
Cleaning Up the Dirt of the Nineties - How New Protocols are Modernizing the Web
PDF
Jenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
PDF
Docker & ci
PDF
Continuous Delivery Pipeline with Docker and Jenkins
PPTX
Continuous Integration With Jenkins Docker SQL Server
Jenkins, pipeline and docker
7 Habits of Highly Effective Jenkins Users
Codifying the Build and Release Process with a Jenkins Pipeline Shared Library
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
Continuous Delivery - Pipeline as-code
Brujug Jenkins pipeline scalability
CI/CD on Android project via Jenkins Pipeline
Let's go HTTPS-only! - More Than Buying a Certificate
Voxxed Luxembourd 2016 Jenkins 2.0 et Pipeline as code
sed.pdf
Jenkins vs. AWS CodePipeline (AWS User Group Berlin)
Jenkins pipeline as code
OSDC 2017 - Julien Pivotto - Automating Jenkins
Monitoring Akka with Kamon 1.0
Cleaning Up the Dirt of the Nineties - How New Protocols are Modernizing the Web
Jenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
Docker & ci
Continuous Delivery Pipeline with Docker and Jenkins
Continuous Integration With Jenkins Docker SQL Server
Ad

Viewers also liked (18)

PPTX
Delivery Pipeline as Code: using Jenkins 2.0 Pipeline
PDF
JavaOne Ignite 2016 - How to build your own self-driving car
PDF
VJUG 24 - Building microservices with Vert.x
PDF
JavaZone 2016: Continuous performance
PDF
Devoxx UK 2016 - Building microservices with Vert.x
PDF
Utrecht JUG - Building microservices with Vert.x
PDF
Codemotion Amsterdam 2016 - The DevOps Disaster
PDF
Utrecht JUG - Pipeline as code
PDF
Zero To Cloud (OSCon 2014)
PDF
Continuous Delivery As Code
PDF
Pipeline: Continuous Delivery as Code in Jenkins 2.0
PPTX
SD DevOps Meet-up - Jenkins 2.0 and Pipeline-as-Code
PDF
Jenkins 20
PDF
Jfokus 2017 - The DevOps Disaster
PPTX
DevOps Practices: Configuration as Code
PDF
JavaLand 2017 - Pipeline as code
PDF
Digital Ocean Amsterdam meetup March 2017 - The DevOps disaster
PDF
Configuration As Code - Adoption of the Job DSL Plugin at Netflix
Delivery Pipeline as Code: using Jenkins 2.0 Pipeline
JavaOne Ignite 2016 - How to build your own self-driving car
VJUG 24 - Building microservices with Vert.x
JavaZone 2016: Continuous performance
Devoxx UK 2016 - Building microservices with Vert.x
Utrecht JUG - Building microservices with Vert.x
Codemotion Amsterdam 2016 - The DevOps Disaster
Utrecht JUG - Pipeline as code
Zero To Cloud (OSCon 2014)
Continuous Delivery As Code
Pipeline: Continuous Delivery as Code in Jenkins 2.0
SD DevOps Meet-up - Jenkins 2.0 and Pipeline-as-Code
Jenkins 20
Jfokus 2017 - The DevOps Disaster
DevOps Practices: Configuration as Code
JavaLand 2017 - Pipeline as code
Digital Ocean Amsterdam meetup March 2017 - The DevOps disaster
Configuration As Code - Adoption of the Job DSL Plugin at Netflix
Ad

Similar to JavaOne 2016 - Pipeline as code (20)

PDF
The Job DSL Plugin: Introduction & What’s New
PPT
Jenkins CI
PPTX
varun JENKINS.pptx
PDF
Juc boston2014.pptx
PDF
JUC Europe 2015: Configuration as Code: The Job DSL Plugin
PPTX
Continous Integration.pptx
PPTX
Trusting the Unknown
PPTX
Trusting the Unknown
PPTX
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
PDF
Continuous Integration using Jenkins with Python
PPTX
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
PPTX
Jenkins presentation
PPTX
Jenkins as a Service - Code all the way down
PDF
Super Charged Configuration As Code
PDF
Atlanta Jenkins Area Meetup October 22nd 2015
PPT
Introduction to Subversion and Google Project Hosting
PDF
413450-rc218-cdw-jenkins-workflow
PPTX
Continuous Integration & Development with Gitlab
PDF
Docker and Puppet for Continuous Integration
PPTX
Contineous integration
The Job DSL Plugin: Introduction & What’s New
Jenkins CI
varun JENKINS.pptx
Juc boston2014.pptx
JUC Europe 2015: Configuration as Code: The Job DSL Plugin
Continous Integration.pptx
Trusting the Unknown
Trusting the Unknown
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Continuous Integration using Jenkins with Python
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
Jenkins presentation
Jenkins as a Service - Code all the way down
Super Charged Configuration As Code
Atlanta Jenkins Area Meetup October 22nd 2015
Introduction to Subversion and Google Project Hosting
413450-rc218-cdw-jenkins-workflow
Continuous Integration & Development with Gitlab
Docker and Puppet for Continuous Integration
Contineous integration

Recently uploaded (20)

PPT
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PPTX
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
PPTX
Digital Literacy And Online Safety on internet
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PPTX
Introduction to Information and Communication Technology
PDF
Testing WebRTC applications at scale.pdf
PPTX
E -tech empowerment technologies PowerPoint
PDF
Cloud-Scale Log Monitoring _ Datadog.pdf
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PDF
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
PDF
How to Ensure Data Integrity During Shopify Migration_ Best Practices for Sec...
PPTX
SAP Ariba Sourcing PPT for learning material
PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
PPTX
Funds Management Learning Material for Beg
PPTX
Introuction about ICD -10 and ICD-11 PPT.pptx
PPTX
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
PDF
RPKI Status Update, presented by Makito Lay at IDNOG 10
PPTX
522797556-Unit-2-Temperature-measurement-1-1.pptx
PPT
tcp ip networks nd ip layering assotred slides
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
Job_Card_System_Styled_lorem_ipsum_.pptx
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
Digital Literacy And Online Safety on internet
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
Introduction to Information and Communication Technology
Testing WebRTC applications at scale.pdf
E -tech empowerment technologies PowerPoint
Cloud-Scale Log Monitoring _ Datadog.pdf
Tenda Login Guide: Access Your Router in 5 Easy Steps
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
How to Ensure Data Integrity During Shopify Migration_ Best Practices for Sec...
SAP Ariba Sourcing PPT for learning material
INTERNET------BASICS-------UPDATED PPT PRESENTATION
Funds Management Learning Material for Beg
Introuction about ICD -10 and ICD-11 PPT.pptx
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
RPKI Status Update, presented by Makito Lay at IDNOG 10
522797556-Unit-2-Temperature-measurement-1-1.pptx
tcp ip networks nd ip layering assotred slides

JavaOne 2016 - Pipeline as code