SlideShare a Scribd company logo
1 of 44
1
Jenkins Days Workshop
Let’s Build a Jenkins
Pipeline
3
Goals for today
Install Jenkins Enterprise
Create a Jenkins Pipeline
Try the basics
See what else is possible and get connected!
Welcome!
1
2
3
4
About your guide: Eric Long
4
Hands-on Delivery experience on CloudBees Jenkins and Pipelines
Senior DevOps Consultant
@ericlongtx
What is Jenkins?
5
Well that’s a funny question.
A CI server? A CD Server?
An automation server
Easy to Start
6
java -jar jenkins.war
CloudBees Jenkins Enterprise
… part of CloudBees Jenkins Platform
7
Jenkins for the EnterpriseCommunity Innovation
What is Jenkins Pipeline?
● Formerly known as Jenkins Workflow, Jenkins Pipeline was introduced in
2014
● New job type – a single Groovy script using an embedded DSL - no need to
jump between multiple job configuration screens to see what is going on
● Durable - keeps running even if Jenkins master is not
● Distributable – a Pipeline job may be run across an unlimited number of
nodes, including in parallel
● Pausable – allows waiting for input from users before continuing to the next
step
● Visualized - Pipeline Stage View provides status at-a-glance dashboards to
include trending
8
Lab Exercise:
Install Jenkins Enterprise
Install Jenkins Enterprise
10
Have Docker?
No Docker? No problem.
https://www.cloudbees.com/get-started
docker run -d -p 80:8080 --name cje -v
/var/run/docker.sock:/var/run/docker.sock beedemo/jenkins-
enterprise-trial
Finish Install
Unlock Jenkins
Request a trial license
Install suggested plugins
Create First Admin User
11
docker logs -f cje
Jenkins initial setup is required. An admin user has been created and a
password generated.
Please use the following password to proceed to installation:
1a90312e459b4d4693f18d48d102d6c6
Lab Exercise:
Create a Pipeline
Pipeline: a new job type
Key Benefits
✓ Long-running
✓ Durable
✓ Scriptable
✓ One-place for Everything
Pipeline: a new job type
✓ Makes building Pipelines
Simple
Domain Specific Language
15
Simple, Groovy-based DSL (“Domain Specific Language”) to
manage build step orchestration
Can be defined as DSL in Jenkins or as Jenkinsfile in SCM
Groovy is widely used in Jenkins ecosystem. You can leverage
the large Jenkins Groovy experience
If you don’t like/care about Groovy, just consider the DSL as a
dedicated simple syntax
Snippet Generator
16
Create a Pipeline - core steps
17
stage - group your steps into its component parts and control
concurrency
node - schedules the steps to run by adding them to Jenkins'
build queue and creates a workspace specific to this pipeline
sh (or bat) - execute shell (*nix) or batch scripts (Windows)
just like freestyle jobs, calling any tools in the agent
Create a Pipeline
stage('build')
echo 'hello from jenkins master'
node {
sh 'echo hello from jenkins agent'
}
stage('test')
echo 'test some things'
stage('deploy')
echo 'deploy some things'
18
Lab Exercise:
Checkout from SCM
Files
stash - store some files for later use
unstash - retrieve previously stashed files (even across
nodes)
writeFile - write a file to the workspace
readFile - read a file from the workspace
20
Checkout from SCM and stash Files
stage('build')
node {
git 'https://github.com/beedemo/mobile-deposit-api.git'
writeFile encoding: 'UTF-8', file: 'config', text:
'version=1'
stash includes: 'pom.xml,config', name: 'pom-config'
}
stage('test')
node {
unstash 'pom-config'
configValue = readFile encoding: 'UTF-8', file: 'config'
echo configValue
}
21
try up to N times
retry(5) {
// some block
}
wait for a condition
waitUntil {
// some block
}
Flow Control
22
wait for a set time
sleep time: 1000, unit:'NANOSECONDS'
timeout
timeout(time: 30, unit: 'SECONDS'){
// some block
}
You can also rely on Groovy control flow syntax!
while(something) {
// do something
if (something_else) {
// do something else
}
}
Flow Control
23
try{
//some things
}catch(e){
//
}
Advanced Flow Control
input - pause for manual or automated approval
parallel - allows simultaneous execution of build steps on the current
node or across nodes, thus increasing build speed
parallel 'quality scan': {
node {sh 'mvn sonar:sonar'}
}, 'integration test': {
node {sh 'mvn verify'}
}
checkpoint - capture the workspace state so it can be reused
as a starting point for subsequent runs
Lab Exercise:
Input and Checkpoints
Input Approval & Checkpoints
26
stage('deploy')
input message: 'Do you want to deploy?'
node {
echo 'deployed'
}
Input Approval & Checkpoints
27
checkpoint 'testing-complete'
stage('approve')
mail body: "Approval needed for '${env.JOB_NAME}' at
${env.BUILD_URL}, subject: "${env.JOB_NAME}
Approval",
to: "ops@acme.com"
timeout(time: 7, unit: 'DAYS') {
input message: 'Do you want to deploy?',
parameters: [string(defaultValue: '', description:
'Provide any comments regarding decision.', name:
'Comments')], submitter: 'ops'
}
Lab Exercise:
Tool Management
tool Step
● Binds a tool installation to a variable
● The tool home directory is returned
● Only tools already configured are available
def mvnHome = tool 'M3'
sh "${mvnHome}/bin/mvn -B verify"
29
Use Docker Containers
● The CloudBees Docker Pipeline plugin allows running steps
inside a container
● You can even build the container as part of the same
Pipeline
docker.image('maven:3.3.3-jdk-8').inside() {
sh 'mvn -B verify'
}
30
Lab Exercise:
Pipeline as Code
Pipeline script in SCM
32
33
Pipeline-as-Code
Pipeline Multibranch
34
Pipeline Shared Libraries
35
What Next?
More Advanced Steps
Send email
mail body: 'Uh oh.', subject: 'Build Failed!', to: 'dev@cloudbees.com'
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients:
'info@cloudbees.com'])
Deploy to Amazon Elastic Beanstalk
wrap([$class: 'AmazonAwsCliBuildWrapper', credentialsId: 'aws-
beanstalk-credentials', defaultRegion: 'us-east-1']) {
sh 'aws elasticbeanstalk create-application-version'
}
Integrate with Jira
jiraComment(issueKey: "EX-111", body: "Job '${env.JOB_NAME}'
(${env.BUILD_NUMBER}) built. Please go to ${env.BUILD_URL}.")
37
@issc29 #JenkinsWorld
Docker + Pipelines
© 2016 CloudBees, Inc. All Rights Reserved
@issc29 #JenkinsWorld
Agent
Gartner: “Using Docker to Run Build Nodes is Ideal.”
© 2016 CloudBees, Inc. All Rights Reserved
Master
z
Agent
Agent
@issc29 #JenkinsWorld
Accelerating CD with Containers
Workflow CD Pipeline Triggers:
✓ New application code (feature, bug fix, etc.)
✓ Updated certified stack (security fix in Linux, etc.)
✓ Will lead to a new gold image being built and
available for … TESTING … STAGING … PRODUCTION
✓ All taking place in a standardized/similar/consistent OS
environment
© 2016 CloudBees, Inc. All Rights Reserved
+
Jenkins Pipeline
TEST
STAGE
PRODUCTIO
N
App
<code>
(git, etc.)
Gold
Docker
Image
(~per app)
<OS config>
Certified
Docker
Images
(Ubuntu, etc.)
<OS config>
@issc29 #JenkinsWorld
Jenkins Pipeline Docker Commands
• withRegistry
– Specifies which Docker Registry to use for pushing/pulling
• withServer
– Specifies which Server to issue Docker commands against
• Build
– Builds container from Dockerfile
• Image.run
– Runs a container
• Image.inside
– Runs container and allows you to execute command inside the container
• Image.push
– Pushed image to Docker Registry with specified credentials
© 2016 CloudBees, Inc. All Rights Reserved
@issc29 #JenkinsWorld
Pipeline - Docker Example
stage 'Build'
node('docker-cloud') {
checkout scm
docker.image('java:jdk-8').inside('-v
/data:/data') {
sh "mvn clean package" }}
© 2016 CloudBees, Inc. All Rights Reserved
stage 'Quality Analysis'
node('docker-cloud') {
unstash 'pom'
parallel(
JRE8Test: {
docker.image('java:jre-8').inside('-v /data:/data') {
sh 'mvn -Dmaven.repo.local=/data/mvn/repo
verify' }
},JRE7Test: {
docker.image('java:jre-7').inside('-v /data:/data') {
sh 'mvn -Dmaven.repo.local=/data/mvn/repo
verify' }
}, failFast: true )}
@issc29 #JenkinsWorld
Pipeline - Docker Example
node('docker-cloud') {
stage 'Build Docker Image'
dir('target') {
mobileDepositApiImage = docker.build "beedemo/mobile-deposit-api:${dockerTag}"
}
stage 'Publish Docker Image'
withDockerRegistry(registry: [credentialsId: 'docker-hub-beedemo']) {
mobileDepositApiImage.push()
}
}
© 2016 CloudBees, Inc. All Rights Reserved
Get Involved!
https://go.cloudbees.com/solutions/pipelines.html
https://jenkins.io/doc/pipeline/
https://jenkins.io/doc/pipeline/steps/
44
Twitter
@ericlongtx

More Related Content

What's hot

Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practicesfloydophone
 
Introduction to java (revised)
Introduction to java (revised)Introduction to java (revised)
Introduction to java (revised)Sujit Majety
 
Web automation using selenium.ppt
Web automation using selenium.pptWeb automation using selenium.ppt
Web automation using selenium.pptAna Sarbescu
 
Modern UI Development With Node.js
Modern UI Development With Node.jsModern UI Development With Node.js
Modern UI Development With Node.jsRyan Anklam
 
Introduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageIntroduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageejlp12
 
Virtual Machines and Docker
Virtual Machines and DockerVirtual Machines and Docker
Virtual Machines and DockerDanish Khakwani
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Domenic Denicola
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions WebStackAcademy
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation洪 鹏发
 
An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)iFour Technolab Pvt. Ltd.
 
Design Pattern - Factory Method Pattern
Design Pattern - Factory Method PatternDesign Pattern - Factory Method Pattern
Design Pattern - Factory Method PatternMudasir Qazi
 
Automation testing IBM RFT - Rational Functional Tester
Automation testing IBM RFT - Rational Functional TesterAutomation testing IBM RFT - Rational Functional Tester
Automation testing IBM RFT - Rational Functional TesterVijayChowthri Nagaprakasham
 

What's hot (20)

Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practices
 
React hooks
React hooksReact hooks
React hooks
 
React hooks
React hooksReact hooks
React hooks
 
Introduction to java (revised)
Introduction to java (revised)Introduction to java (revised)
Introduction to java (revised)
 
PHP Presentation
PHP PresentationPHP Presentation
PHP Presentation
 
Java
JavaJava
Java
 
Js ppt
Js pptJs ppt
Js ppt
 
Web automation using selenium.ppt
Web automation using selenium.pptWeb automation using selenium.ppt
Web automation using selenium.ppt
 
Modern UI Development With Node.js
Modern UI Development With Node.jsModern UI Development With Node.js
Modern UI Development With Node.js
 
Introduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageIntroduction to Docker storage, volume and image
Introduction to Docker storage, volume and image
 
Virtual Machines and Docker
Virtual Machines and DockerVirtual Machines and Docker
Virtual Machines and Docker
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
 
React hooks
React hooksReact hooks
React hooks
 
An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)
 
Design Pattern - Factory Method Pattern
Design Pattern - Factory Method PatternDesign Pattern - Factory Method Pattern
Design Pattern - Factory Method Pattern
 
Automation testing IBM RFT - Rational Functional Tester
Automation testing IBM RFT - Rational Functional TesterAutomation testing IBM RFT - Rational Functional Tester
Automation testing IBM RFT - Rational Functional Tester
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 

Viewers also liked

Continuous Development Pipeline
Continuous Development PipelineContinuous Development Pipeline
Continuous Development PipelineIzzet Mustafaiev
 
Delivery Pipeline as Code: using Jenkins 2.0 Pipeline
Delivery Pipeline as Code: using Jenkins 2.0 PipelineDelivery Pipeline as Code: using Jenkins 2.0 Pipeline
Delivery Pipeline as Code: using Jenkins 2.0 PipelineSlawa Giterman
 
Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)
Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)
Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)CloudBees
 
Seven Habits of Highly Effective Jenkins Users (2014 edition!)
Seven Habits of Highly Effective Jenkins Users (2014 edition!)Seven Habits of Highly Effective Jenkins Users (2014 edition!)
Seven Habits of Highly Effective Jenkins Users (2014 edition!)Andrew Bayer
 
Jenkins JobDSL - Configuration as code
Jenkins JobDSL - Configuration as codeJenkins JobDSL - Configuration as code
Jenkins JobDSL - Configuration as codetomasnorre
 
Jumping from Continuous Integration to Continuous Delivery with Jenkins Enter...
Jumping from Continuous Integration to Continuous Delivery with Jenkins Enter...Jumping from Continuous Integration to Continuous Delivery with Jenkins Enter...
Jumping from Continuous Integration to Continuous Delivery with Jenkins Enter...CloudBees
 
Introduction to Amazon EC2 Container Service and setting up build pipeline wi...
Introduction to Amazon EC2 Container Service and setting up build pipeline wi...Introduction to Amazon EC2 Container Service and setting up build pipeline wi...
Introduction to Amazon EC2 Container Service and setting up build pipeline wi...Swapnil Dahiphale
 
Jenkins hudsonci-101002103143-phpapp02
Jenkins hudsonci-101002103143-phpapp02Jenkins hudsonci-101002103143-phpapp02
Jenkins hudsonci-101002103143-phpapp02Praveen Pamula
 
Native iphone app test automation with appium
Native iphone app test automation with appiumNative iphone app test automation with appium
Native iphone app test automation with appiumJames Eisenhauer
 
Pipeline as code - new feature in Jenkins 2
Pipeline as code - new feature in Jenkins 2Pipeline as code - new feature in Jenkins 2
Pipeline as code - new feature in Jenkins 2Michal Ziarnik
 
Jenkins Plugin Development With Gradle And Groovy
Jenkins Plugin Development With Gradle And GroovyJenkins Plugin Development With Gradle And Groovy
Jenkins Plugin Development With Gradle And GroovyDaniel Spilker
 
Using PaaS for Continuous Delivery (Cloud Foundry Summit 2014)
Using PaaS for Continuous Delivery (Cloud Foundry Summit 2014)Using PaaS for Continuous Delivery (Cloud Foundry Summit 2014)
Using PaaS for Continuous Delivery (Cloud Foundry Summit 2014)VMware Tanzu
 
Super Charged Configuration As Code
Super Charged Configuration As CodeSuper Charged Configuration As Code
Super Charged Configuration As CodeAlan Beale
 
JCConf2016 Jenkins Pipeline
JCConf2016 Jenkins PipelineJCConf2016 Jenkins Pipeline
JCConf2016 Jenkins PipelineChing Yi Chan
 
Continuous Delivery of Puppet-Based Infrastructure - PuppetConf 2014
Continuous Delivery of Puppet-Based Infrastructure - PuppetConf 2014Continuous Delivery of Puppet-Based Infrastructure - PuppetConf 2014
Continuous Delivery of Puppet-Based Infrastructure - PuppetConf 2014Puppet
 
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)Gareth Bowles
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Puppet
 
Synchronizing parallel delivery flows in jenkins using groovy, build flow and...
Synchronizing parallel delivery flows in jenkins using groovy, build flow and...Synchronizing parallel delivery flows in jenkins using groovy, build flow and...
Synchronizing parallel delivery flows in jenkins using groovy, build flow and...Andrey Devyatkin
 

Viewers also liked (20)

Continuous Development Pipeline
Continuous Development PipelineContinuous Development Pipeline
Continuous Development Pipeline
 
Delivery Pipeline as Code: using Jenkins 2.0 Pipeline
Delivery Pipeline as Code: using Jenkins 2.0 PipelineDelivery Pipeline as Code: using Jenkins 2.0 Pipeline
Delivery Pipeline as Code: using Jenkins 2.0 Pipeline
 
Jenkins Pipelines
Jenkins PipelinesJenkins Pipelines
Jenkins Pipelines
 
Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)
Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)
Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)
 
Seven Habits of Highly Effective Jenkins Users (2014 edition!)
Seven Habits of Highly Effective Jenkins Users (2014 edition!)Seven Habits of Highly Effective Jenkins Users (2014 edition!)
Seven Habits of Highly Effective Jenkins Users (2014 edition!)
 
Jenkins JobDSL - Configuration as code
Jenkins JobDSL - Configuration as codeJenkins JobDSL - Configuration as code
Jenkins JobDSL - Configuration as code
 
Jumping from Continuous Integration to Continuous Delivery with Jenkins Enter...
Jumping from Continuous Integration to Continuous Delivery with Jenkins Enter...Jumping from Continuous Integration to Continuous Delivery with Jenkins Enter...
Jumping from Continuous Integration to Continuous Delivery with Jenkins Enter...
 
Introduction to Amazon EC2 Container Service and setting up build pipeline wi...
Introduction to Amazon EC2 Container Service and setting up build pipeline wi...Introduction to Amazon EC2 Container Service and setting up build pipeline wi...
Introduction to Amazon EC2 Container Service and setting up build pipeline wi...
 
Jenkins hudsonci-101002103143-phpapp02
Jenkins hudsonci-101002103143-phpapp02Jenkins hudsonci-101002103143-phpapp02
Jenkins hudsonci-101002103143-phpapp02
 
Native iphone app test automation with appium
Native iphone app test automation with appiumNative iphone app test automation with appium
Native iphone app test automation with appium
 
Pipeline as code - new feature in Jenkins 2
Pipeline as code - new feature in Jenkins 2Pipeline as code - new feature in Jenkins 2
Pipeline as code - new feature in Jenkins 2
 
Jenkins Plugin Development With Gradle And Groovy
Jenkins Plugin Development With Gradle And GroovyJenkins Plugin Development With Gradle And Groovy
Jenkins Plugin Development With Gradle And Groovy
 
Using PaaS for Continuous Delivery (Cloud Foundry Summit 2014)
Using PaaS for Continuous Delivery (Cloud Foundry Summit 2014)Using PaaS for Continuous Delivery (Cloud Foundry Summit 2014)
Using PaaS for Continuous Delivery (Cloud Foundry Summit 2014)
 
Super Charged Configuration As Code
Super Charged Configuration As CodeSuper Charged Configuration As Code
Super Charged Configuration As Code
 
JCConf2016 Jenkins Pipeline
JCConf2016 Jenkins PipelineJCConf2016 Jenkins Pipeline
JCConf2016 Jenkins Pipeline
 
Jenkins Job DSL plugin
Jenkins Job DSL plugin Jenkins Job DSL plugin
Jenkins Job DSL plugin
 
Continuous Delivery of Puppet-Based Infrastructure - PuppetConf 2014
Continuous Delivery of Puppet-Based Infrastructure - PuppetConf 2014Continuous Delivery of Puppet-Based Infrastructure - PuppetConf 2014
Continuous Delivery of Puppet-Based Infrastructure - PuppetConf 2014
 
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
 
Synchronizing parallel delivery flows in jenkins using groovy, build flow and...
Synchronizing parallel delivery flows in jenkins using groovy, build flow and...Synchronizing parallel delivery flows in jenkins using groovy, build flow and...
Synchronizing parallel delivery flows in jenkins using groovy, build flow and...
 

Similar to Jenkins days workshop pipelines - Eric Long

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 AngelesAndy Pemberton
 
Atlanta Jenkins Area Meetup October 22nd 2015
Atlanta Jenkins Area Meetup October 22nd 2015Atlanta Jenkins Area Meetup October 22nd 2015
Atlanta Jenkins Area Meetup October 22nd 2015Kurt Madel
 
(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines(Declarative) Jenkins Pipelines
(Declarative) Jenkins PipelinesSteffen Gebert
 
413450-rc218-cdw-jenkins-workflow
413450-rc218-cdw-jenkins-workflow413450-rc218-cdw-jenkins-workflow
413450-rc218-cdw-jenkins-workflowAndy Pemberton
 
Building an Extensible, Resumable DSL on Top of Apache Groovy
Building an Extensible, Resumable DSL on Top of Apache GroovyBuilding an Extensible, Resumable DSL on Top of Apache Groovy
Building an Extensible, Resumable DSL on Top of Apache Groovyjgcloudbees
 
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 pipelineKubeAcademy
 
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 adventuresFrits Van Der Holst
 
Continuous Integration With Jenkins Docker SQL Server
Continuous Integration With Jenkins Docker SQL ServerContinuous Integration With Jenkins Docker SQL Server
Continuous Integration With Jenkins Docker SQL ServerChris Adkin
 
OpenShift Build Pipelines @ Lightweight Java User Group Meetup
OpenShift Build Pipelines @ Lightweight Java User Group MeetupOpenShift Build Pipelines @ Lightweight Java User Group Meetup
OpenShift Build Pipelines @ Lightweight Java User Group MeetupTobias Schneck
 
Continuous Delivery with Docker and Amazon ECS
Continuous Delivery with Docker and Amazon ECSContinuous Delivery with Docker and Amazon ECS
Continuous Delivery with Docker and Amazon ECSAmazon Web Services
 
Implementing CI CD UiPath Using Jenkins Plugin
Implementing CI CD UiPath Using Jenkins PluginImplementing CI CD UiPath Using Jenkins Plugin
Implementing CI CD UiPath Using Jenkins PluginSatish Prasad
 
Testing with Jenkins, Selenium and Continuous Deployment
Testing with Jenkins, Selenium and Continuous DeploymentTesting with Jenkins, Selenium and Continuous Deployment
Testing with Jenkins, Selenium and Continuous DeploymentMax Klymyshyn
 
Stockholm Jenkins Area Meetup, March 2017
Stockholm Jenkins Area Meetup, March 2017Stockholm Jenkins Area Meetup, March 2017
Stockholm Jenkins Area Meetup, March 2017Andrey Devyatkin
 
Developer Experience Cloud Native - Become Efficient and Achieve Parity
Developer Experience Cloud Native - Become Efficient and Achieve ParityDeveloper Experience Cloud Native - Become Efficient and Achieve Parity
Developer Experience Cloud Native - Become Efficient and Achieve ParityMichael Hofmann
 
Jenkins as a Service - Code all the way down
Jenkins as a Service - Code all the way downJenkins as a Service - Code all the way down
Jenkins as a Service - Code all the way downSteve Mactaggart
 
DevOps World | Jenkins World 2018 and The Future of Jenkins
DevOps World | Jenkins World 2018 and The Future of JenkinsDevOps World | Jenkins World 2018 and The Future of Jenkins
DevOps World | Jenkins World 2018 and The Future of JenkinsNigel Charman
 
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 PipelinesSteffen Gebert
 

Similar to Jenkins days workshop pipelines - Eric Long (20)

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
 
Atlanta Jenkins Area Meetup October 22nd 2015
Atlanta Jenkins Area Meetup October 22nd 2015Atlanta Jenkins Area Meetup October 22nd 2015
Atlanta Jenkins Area Meetup October 22nd 2015
 
(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines
 
413450-rc218-cdw-jenkins-workflow
413450-rc218-cdw-jenkins-workflow413450-rc218-cdw-jenkins-workflow
413450-rc218-cdw-jenkins-workflow
 
Jenkins presentation
Jenkins presentationJenkins presentation
Jenkins presentation
 
Building an Extensible, Resumable DSL on Top of Apache Groovy
Building an Extensible, Resumable DSL on Top of Apache GroovyBuilding an Extensible, Resumable DSL on Top of Apache Groovy
Building an Extensible, Resumable DSL on Top of Apache Groovy
 
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
 
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
 
Continuous Integration With Jenkins Docker SQL Server
Continuous Integration With Jenkins Docker SQL ServerContinuous Integration With Jenkins Docker SQL Server
Continuous Integration With Jenkins Docker SQL Server
 
OpenShift Build Pipelines @ Lightweight Java User Group Meetup
OpenShift Build Pipelines @ Lightweight Java User Group MeetupOpenShift Build Pipelines @ Lightweight Java User Group Meetup
OpenShift Build Pipelines @ Lightweight Java User Group Meetup
 
Continuous Delivery with Docker and Amazon ECS
Continuous Delivery with Docker and Amazon ECSContinuous Delivery with Docker and Amazon ECS
Continuous Delivery with Docker and Amazon ECS
 
Implementing CI CD UiPath Using Jenkins Plugin
Implementing CI CD UiPath Using Jenkins PluginImplementing CI CD UiPath Using Jenkins Plugin
Implementing CI CD UiPath Using Jenkins Plugin
 
Jenkins CI presentation
Jenkins CI presentationJenkins CI presentation
Jenkins CI presentation
 
Testing with Jenkins, Selenium and Continuous Deployment
Testing with Jenkins, Selenium and Continuous DeploymentTesting with Jenkins, Selenium and Continuous Deployment
Testing with Jenkins, Selenium and Continuous Deployment
 
Stockholm Jenkins Area Meetup, March 2017
Stockholm Jenkins Area Meetup, March 2017Stockholm Jenkins Area Meetup, March 2017
Stockholm Jenkins Area Meetup, March 2017
 
Developer Experience Cloud Native - Become Efficient and Achieve Parity
Developer Experience Cloud Native - Become Efficient and Achieve ParityDeveloper Experience Cloud Native - Become Efficient and Achieve Parity
Developer Experience Cloud Native - Become Efficient and Achieve Parity
 
Jenkins as a Service - Code all the way down
Jenkins as a Service - Code all the way downJenkins as a Service - Code all the way down
Jenkins as a Service - Code all the way down
 
DevOps World | Jenkins World 2018 and The Future of Jenkins
DevOps World | Jenkins World 2018 and The Future of JenkinsDevOps World | Jenkins World 2018 and The Future of Jenkins
DevOps World | Jenkins World 2018 and The Future of Jenkins
 
Dockerized maven
Dockerized mavenDockerized maven
Dockerized maven
 
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
 

Recently uploaded

JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profileakrivarotava
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 

Recently uploaded (20)

JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profile
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 

Jenkins days workshop pipelines - Eric Long

  • 1. 1
  • 2. Jenkins Days Workshop Let’s Build a Jenkins Pipeline
  • 3. 3 Goals for today Install Jenkins Enterprise Create a Jenkins Pipeline Try the basics See what else is possible and get connected! Welcome! 1 2 3 4
  • 4. About your guide: Eric Long 4 Hands-on Delivery experience on CloudBees Jenkins and Pipelines Senior DevOps Consultant @ericlongtx
  • 5. What is Jenkins? 5 Well that’s a funny question. A CI server? A CD Server? An automation server
  • 6. Easy to Start 6 java -jar jenkins.war
  • 7. CloudBees Jenkins Enterprise … part of CloudBees Jenkins Platform 7 Jenkins for the EnterpriseCommunity Innovation
  • 8. What is Jenkins Pipeline? ● Formerly known as Jenkins Workflow, Jenkins Pipeline was introduced in 2014 ● New job type – a single Groovy script using an embedded DSL - no need to jump between multiple job configuration screens to see what is going on ● Durable - keeps running even if Jenkins master is not ● Distributable – a Pipeline job may be run across an unlimited number of nodes, including in parallel ● Pausable – allows waiting for input from users before continuing to the next step ● Visualized - Pipeline Stage View provides status at-a-glance dashboards to include trending 8
  • 10. Install Jenkins Enterprise 10 Have Docker? No Docker? No problem. https://www.cloudbees.com/get-started docker run -d -p 80:8080 --name cje -v /var/run/docker.sock:/var/run/docker.sock beedemo/jenkins- enterprise-trial
  • 11. Finish Install Unlock Jenkins Request a trial license Install suggested plugins Create First Admin User 11 docker logs -f cje Jenkins initial setup is required. An admin user has been created and a password generated. Please use the following password to proceed to installation: 1a90312e459b4d4693f18d48d102d6c6
  • 13. Pipeline: a new job type
  • 14. Key Benefits ✓ Long-running ✓ Durable ✓ Scriptable ✓ One-place for Everything Pipeline: a new job type ✓ Makes building Pipelines Simple
  • 15. Domain Specific Language 15 Simple, Groovy-based DSL (“Domain Specific Language”) to manage build step orchestration Can be defined as DSL in Jenkins or as Jenkinsfile in SCM Groovy is widely used in Jenkins ecosystem. You can leverage the large Jenkins Groovy experience If you don’t like/care about Groovy, just consider the DSL as a dedicated simple syntax
  • 17. Create a Pipeline - core steps 17 stage - group your steps into its component parts and control concurrency node - schedules the steps to run by adding them to Jenkins' build queue and creates a workspace specific to this pipeline sh (or bat) - execute shell (*nix) or batch scripts (Windows) just like freestyle jobs, calling any tools in the agent
  • 18. Create a Pipeline stage('build') echo 'hello from jenkins master' node { sh 'echo hello from jenkins agent' } stage('test') echo 'test some things' stage('deploy') echo 'deploy some things' 18
  • 20. Files stash - store some files for later use unstash - retrieve previously stashed files (even across nodes) writeFile - write a file to the workspace readFile - read a file from the workspace 20
  • 21. Checkout from SCM and stash Files stage('build') node { git 'https://github.com/beedemo/mobile-deposit-api.git' writeFile encoding: 'UTF-8', file: 'config', text: 'version=1' stash includes: 'pom.xml,config', name: 'pom-config' } stage('test') node { unstash 'pom-config' configValue = readFile encoding: 'UTF-8', file: 'config' echo configValue } 21
  • 22. try up to N times retry(5) { // some block } wait for a condition waitUntil { // some block } Flow Control 22 wait for a set time sleep time: 1000, unit:'NANOSECONDS' timeout timeout(time: 30, unit: 'SECONDS'){ // some block }
  • 23. You can also rely on Groovy control flow syntax! while(something) { // do something if (something_else) { // do something else } } Flow Control 23 try{ //some things }catch(e){ // }
  • 24. Advanced Flow Control input - pause for manual or automated approval parallel - allows simultaneous execution of build steps on the current node or across nodes, thus increasing build speed parallel 'quality scan': { node {sh 'mvn sonar:sonar'} }, 'integration test': { node {sh 'mvn verify'} } checkpoint - capture the workspace state so it can be reused as a starting point for subsequent runs
  • 25. Lab Exercise: Input and Checkpoints
  • 26. Input Approval & Checkpoints 26 stage('deploy') input message: 'Do you want to deploy?' node { echo 'deployed' }
  • 27. Input Approval & Checkpoints 27 checkpoint 'testing-complete' stage('approve') mail body: "Approval needed for '${env.JOB_NAME}' at ${env.BUILD_URL}, subject: "${env.JOB_NAME} Approval", to: "ops@acme.com" timeout(time: 7, unit: 'DAYS') { input message: 'Do you want to deploy?', parameters: [string(defaultValue: '', description: 'Provide any comments regarding decision.', name: 'Comments')], submitter: 'ops' }
  • 29. tool Step ● Binds a tool installation to a variable ● The tool home directory is returned ● Only tools already configured are available def mvnHome = tool 'M3' sh "${mvnHome}/bin/mvn -B verify" 29
  • 30. Use Docker Containers ● The CloudBees Docker Pipeline plugin allows running steps inside a container ● You can even build the container as part of the same Pipeline docker.image('maven:3.3.3-jdk-8').inside() { sh 'mvn -B verify' } 30
  • 37. More Advanced Steps Send email mail body: 'Uh oh.', subject: 'Build Failed!', to: 'dev@cloudbees.com' step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'info@cloudbees.com']) Deploy to Amazon Elastic Beanstalk wrap([$class: 'AmazonAwsCliBuildWrapper', credentialsId: 'aws- beanstalk-credentials', defaultRegion: 'us-east-1']) { sh 'aws elasticbeanstalk create-application-version' } Integrate with Jira jiraComment(issueKey: "EX-111", body: "Job '${env.JOB_NAME}' (${env.BUILD_NUMBER}) built. Please go to ${env.BUILD_URL}.") 37
  • 38. @issc29 #JenkinsWorld Docker + Pipelines © 2016 CloudBees, Inc. All Rights Reserved
  • 39. @issc29 #JenkinsWorld Agent Gartner: “Using Docker to Run Build Nodes is Ideal.” © 2016 CloudBees, Inc. All Rights Reserved Master z Agent Agent
  • 40. @issc29 #JenkinsWorld Accelerating CD with Containers Workflow CD Pipeline Triggers: ✓ New application code (feature, bug fix, etc.) ✓ Updated certified stack (security fix in Linux, etc.) ✓ Will lead to a new gold image being built and available for … TESTING … STAGING … PRODUCTION ✓ All taking place in a standardized/similar/consistent OS environment © 2016 CloudBees, Inc. All Rights Reserved + Jenkins Pipeline TEST STAGE PRODUCTIO N App <code> (git, etc.) Gold Docker Image (~per app) <OS config> Certified Docker Images (Ubuntu, etc.) <OS config>
  • 41. @issc29 #JenkinsWorld Jenkins Pipeline Docker Commands • withRegistry – Specifies which Docker Registry to use for pushing/pulling • withServer – Specifies which Server to issue Docker commands against • Build – Builds container from Dockerfile • Image.run – Runs a container • Image.inside – Runs container and allows you to execute command inside the container • Image.push – Pushed image to Docker Registry with specified credentials © 2016 CloudBees, Inc. All Rights Reserved
  • 42. @issc29 #JenkinsWorld Pipeline - Docker Example stage 'Build' node('docker-cloud') { checkout scm docker.image('java:jdk-8').inside('-v /data:/data') { sh "mvn clean package" }} © 2016 CloudBees, Inc. All Rights Reserved stage 'Quality Analysis' node('docker-cloud') { unstash 'pom' parallel( JRE8Test: { docker.image('java:jre-8').inside('-v /data:/data') { sh 'mvn -Dmaven.repo.local=/data/mvn/repo verify' } },JRE7Test: { docker.image('java:jre-7').inside('-v /data:/data') { sh 'mvn -Dmaven.repo.local=/data/mvn/repo verify' } }, failFast: true )}
  • 43. @issc29 #JenkinsWorld Pipeline - Docker Example node('docker-cloud') { stage 'Build Docker Image' dir('target') { mobileDepositApiImage = docker.build "beedemo/mobile-deposit-api:${dockerTag}" } stage 'Publish Docker Image' withDockerRegistry(registry: [credentialsId: 'docker-hub-beedemo']) { mobileDepositApiImage.push() } } © 2016 CloudBees, Inc. All Rights Reserved