20
Pipeline as Code Jenkins 2.0 and Pipeline

Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

Embed Size (px)

Citation preview

Page 1: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

Pipeline as CodeJenkins 2.0 and Pipeline

Page 2: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new
Page 3: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

Continuous Delivery

Continuous delivery (CD) is a software engineering approach in which teams produce software in short cycles, ensuring that the software can be reliably released at any time. It aims at building, testing, and releasing software faster and more frequently. The approach helps reduce the cost, time, and risk of delivering changes by allowing for more incremental updates to applications in production. A straightforward and repeatable deployment process is important for continuous delivery.

https://en.wikipedia.org/wiki/Continuous_delivery

Page 4: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

CD with Jenkins 1

Page 5: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

Steps to CD in Jenkins

➢ Ensuring reproducible builds➢ Sharing build artifacts throughout the pipeline➢ Choosing the right granularity for each job➢ Parallelizing and joining jobs➢ Gates and approvals➢ Visualizing the pipeline➢ Organizing and securing jobs➢ Good practice: versioning your Jenkins configuration

http://www.infoq.com/articles/orch-pipelines-jenkins

Page 6: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

CD with Jenkins circa 2014

http://www.infoq.com/articles/orch-pipelines-jenkins

Page 7: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

Static Code Quality Analysis Job

Page 8: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

Approval

Page 9: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

Visualizing the Pipeline

Build Pipeline Plugin Delivery Pipeline Plugin

Page 10: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

SCM Sync Configuration Plugin

Page 11: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

Jenkins Pipeline

Page 12: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

Pipeline as Code

➢ Introduce “pipeline” as a new type in Jenkins➢ Codify an implicit series of stages into an explicit Jenkinsfile in

your source repository➢ Resumability/durability of the pipeline state➢ Extend the DSL with your own steps➢ DRY - Reusable components and flows

github.com/jenkinsci/pipeline-examples

Page 13: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

Pipeline DSL

node('docker') { checkout scm

/* Grab the abbreviated SHA1 of our pipeline’s commit.*/ sh 'git rev-parse HEAD > GIT_COMMIT' def shortCommit = readFile('GIT_COMMIT').take(6)

stage 'Build' def image = docker.build("jenkinsciinfra/bind:build-${shortCommit}")

stage 'Deploy' image.push()}

Page 14: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

Pipeline DSL

Page 15: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

Pipeline Stage View

Page 16: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

Pipeline Stage View

Page 17: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

Durable Task Plugin

Page 18: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

Extensibility

➢ CPS Global Library➢ Remote Loader Plugin➢ ‘load’ step➢ Plugins

Page 19: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

CD with Jenkins circa 2014

http://www.infoq.com/articles/orch-pipelines-jenkins

Page 20: Pipeline as Code - Meetupfiles.meetup.com/19663277/Pipeline as Code Overview - VC 2016.pdf · Build Pipeline Plugin Delivery Pipeline Plugin. ... Introduce “pipeline” as a new

Pipeline

➢ Ensuring reproducible builds➢ Sharing build artifacts throughout the pipeline➢ Choosing the right granularity for each job➢ Parallelizing and joining jobs➢ Gates and approvals➢ Visualizing the pipeline➢ Organizing and securing jobs➢ Good practice: versioning your Jenkins configuration