SlideShare a Scribd company logo
1 of 39
Continuous Delivery
Pipeline as code
Mike van Vendeloo
Software Craftsman at JPoint
TU Delft - Computer Science
Scrum master
Assignments at customers like KLM, Rabobank, Government,
de Persgroep.
Focus on improvement of software development process and
quality
Hobb: Korfball, domotica
@mikevanvendeloo
Agenda
• Definitions CI/CD/Pipeline
• Jenkins 2: Pipeline as code
• Pipeline snippets
• Reuse with pipeline libraries
• Declarative pipelines
• Blue Ocean
• Demo
Definitions
Definitions - Continuous Integration
“Continuous Integration is a software development practice
where members of a team integrate their work frequently,
usually each person integrates at least daily - leading to
multiple integrations per day. Each integration is verified by
an automated build (including test) to detect integration errors
as quickly as possible.“
Martin Fowler
Continuous Delivery: Automate everything
“If it hurts, do it more
frequently, and bring the pain
forward.”
― Jez Humble,
Continuous Delivery
Definitions - Continuous Delivery
“Continuous Delivery is the ability to get changes of all
types—including new features, configuration changes, bug
fixes and experiments—into production, or into the hands of
users, safely and quickly in a sustainable way.”
Definitions - Continuous Deployment
Definitions - Pipeline
A pipeline is a set of stages to bring functionality from developer to the end user.
Jenkins pipeline as code
Jenkins 1
Jenkins 2 - Pipeline as code
Sample basic pipeline stages
➔ Checkout
Source code checkout from repository
➔ Build
Compile & Unit test
➔ QA
Code style check & integration testing
➔ Deploy
Deploy to a server
Basic pipeline definition
#!/usr/bin/groovy
node('linux') {
stage('Checkout') {
checkout scm
}
stage('Build') {
sh "mvn clean deploy"
junit allowEmptyResults: true, testResults: 'target/surefire-reports/*.xml'
}
stage('Deploy') {
build "Deployer"
}
}
Pipeline snippets
Error handling
node {
stage('Doing my thing') {
try {
sh 'exit 1'
} catch (someException) {
echo 'Something failed, somebody should be notified!'
throw someException
} finally {
hipchatSend color: 'BLUE', credentialId: 'hipChat', message: “Build result
${env.BUILD_RESULT}”, room: 'BuildResults'
}
}
}
Pipeline properties - cleanup
properties(
[buildDiscarder(
logRotator(
artifactDaysToKeepStr: '',
artifactNumToKeepStr: '',
daysToKeepStr: '7',
numToKeepStr: '25')
),
pipelineTriggers([])
]
)
Pipeline properties - Parameters
properties(
[parameters(
[choice(
choices: ['dev', 'test', 'acc', 'prod'], description: 'Kies de omgeving', name: 'omgeving')]
),
pipelineTriggers([])
])
Parallel tasks
parallel ‘test’: {
sh ‘mvn clean test’
}, ‘mutation-test’: {
Sh ‘mvn org.pitest:pitest-maven:mutationCoverage’
},
failFast: true
Share information between nodes/executors
node {
stage(‘Build’)
sh(“mvn -B clean package”)
stash excludes:’target/’, includes: ‘**’, name: ‘source’
}
stage (‘test’) {
unstash ‘source’
}
}
Notifications
def notify(String colorCode, String color, String summary)
slackSend (color: colorCode, message: summary)
hipchatSend (color: color, notify: true, message: summary)
emailext (
to: team@mydomain.com',
subject: “Build ${env.JOB_NAME} [${env.BUILD_NUMBER}] result ${currentBuild.result}”
body: “<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>”,
recipientProviders: [[$class: 'DevelopersRecipientProvider']]
)
}
Pipeline libraries
Reuse between pipelines: libraries
Library implementation
package vanvendeloo.jenkins
def checkout(String repositoryName) {
git “git@bitbucket.org:vanvendeloo/${repositoryName}”
}
def updateVersion() {
sh “mvn build-helper:parse-version versions:set -
DnewVersion=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${
parsedVersion.nextIncrementalVersion} versions:commit”
}
// Return the contents of this script as object so it can be re-used in Jenkinsfiles.
return this
Use the library: @Library
@Library(‘pipeline-library’)
node {
pipelineSteps = new PipelineSteps()
stage(‘Preparation’) {
pipelineSteps.checkout(‘my-service’)
pipelineSteps.updateVersion()
}
}
Catch: Groovy Sandbox
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: ↵
Scripts not permitted to use method java.lang.String replaceAll java.lang.String
java.lang.String
1. Go to Manage Jenkins > In-process
Script Approval
2. Review the pending signatures and
click Approve to add them to the
whitelist
3. Re-run your job; it should no longer
fail (for this particular method call)
Declarative pipelines
Declarative Pipelines
node {
stage(‘Checkout’) {
checkout scm
}
stage(‘Build’) {
withEnv(["PATH+MAVEN=${tool 'M3'}/bin"]) {
try {
sh 'mvn clean install'
} catch (e) {
currentBuild.result = 'FAILURE'
}
}
}
pipeline {
agent any
tools { maven 'M3' }
stages {
stage('Checkout') {
steps { checkout scm }
}
stage(Build) {
steps {
sh ‘mvn clean install’
}
post {
success {
junit '**/surefire-reports/**/*.xml'
}
}
}
}
Blue Ocean
Blue Ocean
Pipeline result
Conclusions
Pipeline evaluates with your code
Reuse in libraries keeps your Jenkinsfile clean and simple
BlueOcean definately an improvement, but need to get used to it
Pipeline editor very cool feature!
http://github.com/mikevanvendeloo
https://jenkins.io/doc/book/pipeline/syntax/
https://jenkins.io/blog/2017/02/07/declarative-maven-project/
Resources
@mikevanvendeloo

More Related Content

What's hot

413450-rc218-cdw-jenkins-workflow
413450-rc218-cdw-jenkins-workflow413450-rc218-cdw-jenkins-workflow
413450-rc218-cdw-jenkins-workflow
Andy Pemberton
 

What's hot (20)

7 Habits of Highly Effective Jenkins Users
7 Habits of Highly Effective Jenkins Users7 Habits of Highly Effective Jenkins Users
7 Habits of Highly Effective Jenkins Users
 
Jenkins days workshop pipelines - Eric Long
Jenkins days workshop  pipelines - Eric LongJenkins days workshop  pipelines - Eric Long
Jenkins days workshop pipelines - Eric Long
 
sed.pdf
sed.pdfsed.pdf
sed.pdf
 
Brujug Jenkins pipeline scalability
Brujug Jenkins pipeline scalabilityBrujug Jenkins pipeline scalability
Brujug Jenkins pipeline scalability
 
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins PipelinesAn Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
 
Jenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
Jenkins Days - Workshop - Let's Build a Pipeline - Los AngelesJenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
Jenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
 
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems IntegrationJenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
 
Jenkins pipeline as code
Jenkins pipeline as codeJenkins pipeline as code
Jenkins pipeline as code
 
Continuous Delivery Pipeline with Docker and Jenkins
Continuous Delivery Pipeline with Docker and JenkinsContinuous Delivery Pipeline with Docker and Jenkins
Continuous Delivery Pipeline with Docker and Jenkins
 
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
 
Jenkins Pipelines
Jenkins PipelinesJenkins Pipelines
Jenkins Pipelines
 
Building Jenkins Pipelines at Scale
Building Jenkins Pipelines at ScaleBuilding Jenkins Pipelines at Scale
Building Jenkins Pipelines at Scale
 
Monitoring Akka with Kamon 1.0
Monitoring Akka with Kamon 1.0Monitoring Akka with Kamon 1.0
Monitoring Akka with Kamon 1.0
 
Codifying the Build and Release Process with a Jenkins Pipeline Shared Library
Codifying the Build and Release Process with a Jenkins Pipeline Shared LibraryCodifying the Build and Release Process with a Jenkins Pipeline Shared Library
Codifying the Build and Release Process with a Jenkins Pipeline Shared Library
 
Testing with Docker
Testing with DockerTesting with Docker
Testing with Docker
 
Let's go HTTPS-only! - More Than Buying a Certificate
Let's go HTTPS-only! - More Than Buying a CertificateLet's go HTTPS-only! - More Than Buying a Certificate
Let's go HTTPS-only! - More Than Buying a Certificate
 
Pimp your jenkins platform with docker - Devops.com 2015/11
Pimp your jenkins platform with docker - Devops.com 2015/11Pimp your jenkins platform with docker - Devops.com 2015/11
Pimp your jenkins platform with docker - Devops.com 2015/11
 
Ci with jenkins docker and mssql belgium
Ci with jenkins docker and mssql belgiumCi with jenkins docker and mssql belgium
Ci with jenkins docker and mssql belgium
 
413450-rc218-cdw-jenkins-workflow
413450-rc218-cdw-jenkins-workflow413450-rc218-cdw-jenkins-workflow
413450-rc218-cdw-jenkins-workflow
 
Automated acceptance test
Automated acceptance testAutomated acceptance test
Automated acceptance test
 

Viewers also liked

Viewers also liked (20)

Digital in 2016
Digital in 2016Digital in 2016
Digital in 2016
 
Making Makers: Making as a Pathway to Engineering
Making Makers: Making as a Pathway to EngineeringMaking Makers: Making as a Pathway to Engineering
Making Makers: Making as a Pathway to Engineering
 
Zero To Cloud (OSCon 2014)
Zero To Cloud (OSCon 2014)Zero To Cloud (OSCon 2014)
Zero To Cloud (OSCon 2014)
 
AWS Code{Commit,Deploy,Pipeline} (June 2016)
 AWS Code{Commit,Deploy,Pipeline} (June 2016) AWS Code{Commit,Deploy,Pipeline} (June 2016)
AWS Code{Commit,Deploy,Pipeline} (June 2016)
 
Part 3: Enabling Continuous Delivery (Pivotal Cloud Platform Roadshow)
Part 3: Enabling Continuous Delivery (Pivotal Cloud Platform Roadshow)Part 3: Enabling Continuous Delivery (Pivotal Cloud Platform Roadshow)
Part 3: Enabling Continuous Delivery (Pivotal Cloud Platform Roadshow)
 
Continuous Development Pipeline
Continuous Development PipelineContinuous Development Pipeline
Continuous Development Pipeline
 
Pipeline: Continuous Delivery as Code in Jenkins 2.0
Pipeline: Continuous Delivery as Code in Jenkins 2.0Pipeline: Continuous Delivery as Code in Jenkins 2.0
Pipeline: Continuous Delivery as Code in Jenkins 2.0
 
Cut the ITIL Anchor, Raise the ITIL Sail, an ITSM Academy Webinar
Cut the ITIL Anchor, Raise the ITIL Sail, an ITSM Academy WebinarCut the ITIL Anchor, Raise the ITIL Sail, an ITSM Academy Webinar
Cut the ITIL Anchor, Raise the ITIL Sail, an ITSM Academy Webinar
 
Enterprise CI as-a-Service using Jenkins
Enterprise CI as-a-Service using JenkinsEnterprise CI as-a-Service using Jenkins
Enterprise CI as-a-Service using Jenkins
 
SD DevOps Meet-up - Jenkins 2.0 and Pipeline-as-Code
SD DevOps Meet-up - Jenkins 2.0 and Pipeline-as-CodeSD DevOps Meet-up - Jenkins 2.0 and Pipeline-as-Code
SD DevOps Meet-up - Jenkins 2.0 and Pipeline-as-Code
 
Agile and ITIL Continuous Delivery
Agile and ITIL Continuous DeliveryAgile and ITIL Continuous Delivery
Agile and ITIL Continuous Delivery
 
CI and CD with Jenkins
CI and CD with JenkinsCI and CD with Jenkins
CI and CD with Jenkins
 
Jenkins - From Continuous Integration to Continuous Delivery
Jenkins - From Continuous Integration to Continuous DeliveryJenkins - From Continuous Integration to Continuous Delivery
Jenkins - From Continuous Integration to Continuous Delivery
 
AWS Code Services
AWS Code ServicesAWS Code Services
AWS Code Services
 
DevOps and Continuous Delivery Reference Architectures - Volume 2
DevOps and Continuous Delivery Reference Architectures - Volume 2DevOps and Continuous Delivery Reference Architectures - Volume 2
DevOps and Continuous Delivery Reference Architectures - Volume 2
 
DevOps Practices: Configuration as Code
DevOps Practices:Configuration as CodeDevOps Practices:Configuration as Code
DevOps Practices: Configuration as Code
 
The Continuous People Pipeline, with Jayne Groll - an ITSM Academy Webinar
The Continuous People Pipeline, with Jayne Groll - an ITSM Academy WebinarThe Continuous People Pipeline, with Jayne Groll - an ITSM Academy Webinar
The Continuous People Pipeline, with Jayne Groll - an ITSM Academy Webinar
 
DevOps
DevOpsDevOps
DevOps
 
DevOps: A Culture Transformation, More than Technology
DevOps: A Culture Transformation, More than TechnologyDevOps: A Culture Transformation, More than Technology
DevOps: A Culture Transformation, More than Technology
 
DevOps 101
DevOps 101DevOps 101
DevOps 101
 

Similar to Continuous Delivery - Pipeline as-code

Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/HudsonEclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
VladLica
 

Similar to Continuous Delivery - Pipeline as-code (20)

Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
 
Shipping Code like a keptn: Continuous Delivery & Automated Operations on k8s
Shipping Code like a keptn: Continuous Delivery & Automated Operations on k8sShipping Code like a keptn: Continuous Delivery & Automated Operations on k8s
Shipping Code like a keptn: Continuous Delivery & Automated Operations on k8s
 
Jenkins Pipelines Advanced
Jenkins Pipelines AdvancedJenkins Pipelines Advanced
Jenkins Pipelines Advanced
 
Moving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventuresMoving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventures
 
CI and CD
CI and CDCI and CD
CI and CD
 
Chicago DevOps Meetup Nov2019
Chicago DevOps Meetup Nov2019Chicago DevOps Meetup Nov2019
Chicago DevOps Meetup Nov2019
 
Anatomy of a Build Pipeline
Anatomy of a Build PipelineAnatomy of a Build Pipeline
Anatomy of a Build Pipeline
 
Don't Deploy Into the Dark: DORA Metrics for your K8s GitOps Deployments
Don't Deploy Into the Dark: DORA Metrics for your K8s GitOps DeploymentsDon't Deploy Into the Dark: DORA Metrics for your K8s GitOps Deployments
Don't Deploy Into the Dark: DORA Metrics for your K8s GitOps Deployments
 
Scala, docker and testing, oh my! mario camou
Scala, docker and testing, oh my! mario camouScala, docker and testing, oh my! mario camou
Scala, docker and testing, oh my! mario camou
 
CI/CD and TDD in deploying kamailio
CI/CD and TDD in deploying kamailioCI/CD and TDD in deploying kamailio
CI/CD and TDD in deploying kamailio
 
Surviving the Script-apocalypse
Surviving the Script-apocalypseSurviving the Script-apocalypse
Surviving the Script-apocalypse
 
Continuos Integration and Delivery: from Zero to Hero with TeamCity, Docker a...
Continuos Integration and Delivery: from Zero to Hero with TeamCity, Docker a...Continuos Integration and Delivery: from Zero to Hero with TeamCity, Docker a...
Continuos Integration and Delivery: from Zero to Hero with TeamCity, Docker a...
 
HashiStack. To the cloud and beyond...
HashiStack. To the cloud and beyond...HashiStack. To the cloud and beyond...
HashiStack. To the cloud and beyond...
 
Dev ops meetup
Dev ops meetupDev ops meetup
Dev ops meetup
 
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
 
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipelineKubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
 
Criando pipelines de entrega contínua multilinguagem com Docker e Jenkins
Criando pipelines de entrega contínua multilinguagem com Docker e JenkinsCriando pipelines de entrega contínua multilinguagem com Docker e Jenkins
Criando pipelines de entrega contínua multilinguagem com Docker e Jenkins
 
Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/HudsonEclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
 
FV04_MostoviczT_RAD
FV04_MostoviczT_RADFV04_MostoviczT_RAD
FV04_MostoviczT_RAD
 
Software Delivery in 2016 - A Continuous Delivery Approach
Software Delivery in 2016 - A Continuous Delivery ApproachSoftware Delivery in 2016 - A Continuous Delivery Approach
Software Delivery in 2016 - A Continuous Delivery Approach
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Continuous Delivery - Pipeline as-code

  • 2. Mike van Vendeloo Software Craftsman at JPoint TU Delft - Computer Science Scrum master Assignments at customers like KLM, Rabobank, Government, de Persgroep. Focus on improvement of software development process and quality Hobb: Korfball, domotica @mikevanvendeloo
  • 3. Agenda • Definitions CI/CD/Pipeline • Jenkins 2: Pipeline as code • Pipeline snippets • Reuse with pipeline libraries • Declarative pipelines • Blue Ocean • Demo
  • 5. Definitions - Continuous Integration “Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily - leading to multiple integrations per day. Each integration is verified by an automated build (including test) to detect integration errors as quickly as possible.“ Martin Fowler
  • 6. Continuous Delivery: Automate everything “If it hurts, do it more frequently, and bring the pain forward.” ― Jez Humble, Continuous Delivery
  • 7. Definitions - Continuous Delivery “Continuous Delivery is the ability to get changes of all types—including new features, configuration changes, bug fixes and experiments—into production, or into the hands of users, safely and quickly in a sustainable way.”
  • 9. Definitions - Pipeline A pipeline is a set of stages to bring functionality from developer to the end user.
  • 12. Jenkins 2 - Pipeline as code
  • 13. Sample basic pipeline stages ➔ Checkout Source code checkout from repository ➔ Build Compile & Unit test ➔ QA Code style check & integration testing ➔ Deploy Deploy to a server
  • 14. Basic pipeline definition #!/usr/bin/groovy node('linux') { stage('Checkout') { checkout scm } stage('Build') { sh "mvn clean deploy" junit allowEmptyResults: true, testResults: 'target/surefire-reports/*.xml' } stage('Deploy') { build "Deployer" } }
  • 15.
  • 17. Error handling node { stage('Doing my thing') { try { sh 'exit 1' } catch (someException) { echo 'Something failed, somebody should be notified!' throw someException } finally { hipchatSend color: 'BLUE', credentialId: 'hipChat', message: “Build result ${env.BUILD_RESULT}”, room: 'BuildResults' } } }
  • 18. Pipeline properties - cleanup properties( [buildDiscarder( logRotator( artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '7', numToKeepStr: '25') ), pipelineTriggers([]) ] )
  • 19. Pipeline properties - Parameters properties( [parameters( [choice( choices: ['dev', 'test', 'acc', 'prod'], description: 'Kies de omgeving', name: 'omgeving')] ), pipelineTriggers([]) ])
  • 20. Parallel tasks parallel ‘test’: { sh ‘mvn clean test’ }, ‘mutation-test’: { Sh ‘mvn org.pitest:pitest-maven:mutationCoverage’ }, failFast: true
  • 21. Share information between nodes/executors node { stage(‘Build’) sh(“mvn -B clean package”) stash excludes:’target/’, includes: ‘**’, name: ‘source’ } stage (‘test’) { unstash ‘source’ } }
  • 22. Notifications def notify(String colorCode, String color, String summary) slackSend (color: colorCode, message: summary) hipchatSend (color: color, notify: true, message: summary) emailext ( to: team@mydomain.com', subject: “Build ${env.JOB_NAME} [${env.BUILD_NUMBER}] result ${currentBuild.result}” body: “<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>”, recipientProviders: [[$class: 'DevelopersRecipientProvider']] ) }
  • 25. Library implementation package vanvendeloo.jenkins def checkout(String repositoryName) { git “git@bitbucket.org:vanvendeloo/${repositoryName}” } def updateVersion() { sh “mvn build-helper:parse-version versions:set - DnewVersion=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${ parsedVersion.nextIncrementalVersion} versions:commit” } // Return the contents of this script as object so it can be re-used in Jenkinsfiles. return this
  • 26. Use the library: @Library @Library(‘pipeline-library’) node { pipelineSteps = new PipelineSteps() stage(‘Preparation’) { pipelineSteps.checkout(‘my-service’) pipelineSteps.updateVersion() } }
  • 27. Catch: Groovy Sandbox org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: ↵ Scripts not permitted to use method java.lang.String replaceAll java.lang.String java.lang.String 1. Go to Manage Jenkins > In-process Script Approval 2. Review the pending signatures and click Approve to add them to the whitelist 3. Re-run your job; it should no longer fail (for this particular method call)
  • 29. Declarative Pipelines node { stage(‘Checkout’) { checkout scm } stage(‘Build’) { withEnv(["PATH+MAVEN=${tool 'M3'}/bin"]) { try { sh 'mvn clean install' } catch (e) { currentBuild.result = 'FAILURE' } } } pipeline { agent any tools { maven 'M3' } stages { stage('Checkout') { steps { checkout scm } } stage(Build) { steps { sh ‘mvn clean install’ } post { success { junit '**/surefire-reports/**/*.xml' } } } }
  • 33.
  • 34.
  • 35.
  • 36. Conclusions Pipeline evaluates with your code Reuse in libraries keeps your Jenkinsfile clean and simple BlueOcean definately an improvement, but need to get used to it Pipeline editor very cool feature!
  • 37.

Editor's Notes

  1. Continuous Delivery is sometimes confused with Continuous Deployment. Continuous Deployment means that every change goes through the pipeline and automatically gets put into production, resulting in many production deployments every day. Continuous Delivery just means that you are able to do frequent deployments but may choose not to do it, usually due to businesses preferring a slower rate of deployment. In order to do Continuous Deployment you must be doing Continuous Delivery.
  2. Pipeline as first class citizen