Jenkins Workflow Webinar - Dec 10, 2014
-
Upload
cloudbees -
Category
Technology
-
view
787 -
download
1
Transcript of Jenkins Workflow Webinar - Dec 10, 2014
Orchestrating the Continuous Delivery Process in Jenkins with Workflow
©2014 CloudBees, Inc. All Rights Reserved 1
Today’s Presenters
Cyrille Le Clerc Director, Product Management
[email protected] @cyrilleleclerc
Steve Harris SVP, Products
[email protected] @stevengharris
©2014 CloudBees, Inc. All Rights Reserved 2
Using WebEx Questions?
Submit via the Q&A window at any time during the presentation.
We will cover Q&A at the end of the presentation.
Session is being recorded.
©2014 CloudBees, Inc. All Rights Reserved 3
Agenda
• Con=nuous Delivery • Jenkins & Con=nuous Delivery • Workflow in Jenkins Today • The New Jenkins Workflow Engine • Jenkins Workflow Syntax Card • Possible Futures
©2014 CloudBees, Inc. All Rights Reserved 4
Continuous Delivery
©2014 CloudBees, Inc. All Rights Reserved 5
Continuous Delivery
• “Reliable So+ware Releases through Build, Test, and Deployment Automa=on”
• DONE = Shippable into Produc=on
©2014 CloudBees, Inc. All Rights Reserved 6
Continuous Integration Steps
Con$
nuou
s Integra$o
n Source Code
Quality Analysis
Compile &Unit Tests
Binaries
©2014 CloudBees, Inc. All Rights Reserved 7
Continuous Delivery Steps
Con$
nuou
s Delivery
DEV
DEV
OPS
QA
Source Code
Quality Analysis
Compile &Unit Tests
Binaries
Perfs Environment
Func Test Environment
UAT Environment
Production Environment
GO LIVE!
Release!
Staging Environment
8
Continuous Delivery Pipeline
Continuous Delivery Pipeline
Compile &Unit Tests
Perfs Tests
Selenium Tests Deploy UAT
Sonar Analysis
Deploy Staging Deploy Production
©2014 CloudBees, Inc. All Rights Reserved 9
Jenkins: Hub of Continuous Delivery
• Connect the dots
• It is the process Source Code
Perfs Environment
Func Test Environment
UAT Environment
Binaries
Quality Analysis
Compile &Unit Tests
©2014 CloudBees, Inc. All Rights Reserved 10
CI/CD with Jenkins and Vagrant and Puppet
Jenkins builds war file and Puppet modules and deploys via Vagrant
puppet deployment
modulejava code
Dev Environment
war file + puppet manifests & modules
vagrant provisionpuppet apply
Prod Environment
Puppet Agentpetclinic.war
App. Server
QA Environment
Puppet Agentpetclinic.war
App. Server
war file + puppet manifests & modules
Puppet Master
Puppet Master
Puppet Agentpetclinic.war
App. Server
OPSwar file + puppet manifests & modules
CI/CD with Jenkins and Vagrant and Puppet
Jenkins builds war file and Puppet modules and deploys via Vagrant
puppet deployment
modulejava code
Dev Environment
war file + puppet manifests & modules
vagrant provisionpuppet apply
notification
Prod Environment
Puppet Agentpetclinic.war
App. Server
QA Environment
Puppet Agentpetclinic.war
App. Server
notificationwar file + puppet manifests & modules
Puppet Master
Puppet Master
Puppet Agentpetclinic.war
App. Server
OPSwar file + puppet manifests & modules
Jenkins – Puppet Integration
CD Pipeline è Workflow
Continuous Delivery Pipeline
Compile &Unit Tests
Perfs Tests
Selenium Tests Deploy UAT
Sonar Analysis
Deploy Staging Deploy Production
©2014 CloudBees, Inc. All Rights Reserved 14
What We Need
• Complex pipelines involving mul=ple stages • Non-‐sequen$al logic such as loops, forks … • Long-‐running builds must survive outages • Interac$ons with humans including pauses, input • Restartable builds in case of transient errors • Reusable defini$ons to avoid duplica=on • Comprehensible scripts with one clear defini=on
©2014 CloudBees, Inc. All Rights Reserved 15
Most Existing Workflow In Jenkins Today
• Job Chaining
• Build Flow Plugin
• Build Pipeline Plugin
• Build Delivery Pipeline
©2014 CloudBees, Inc. All Rights Reserved 16
Most Existing Workflow In Jenkins Today
• Many atomic jobs • Hard to share variables/state between jobs • Limited logic • Mix build triggers, parameterized build …
©2014 CloudBees, Inc. All Rights Reserved 17
Jenkins Workflow Engine
©2014 CloudBees, Inc. All Rights Reserved 18
Simplifying Our Sample Workflow
Compile &Unit Tests
Perfs Tests
Selenium Tests Deploy UAT
Sonar Analysis
Deploy Staging Deploy Production
©2014 CloudBees, Inc. All Rights Reserved 19
Simplifying Our Sample Workflow
Compile &Unit Tests
Perfs Tests
Selenium Tests Deploy UAT
Sonar Analysis
Deploy Staging Deploy Production
©2014 CloudBees, Inc. All Rights Reserved 20
What We Need
• Complex pipelines involving mul=ple stages • Non-‐sequen$al logic such as loops, forks … • Long-‐running builds must survive outages • Interac$ons with humans including pauses, input • Restartable builds in case of transient errors • Reusable defini$ons to avoid duplica=on • Comprehensible scripts with one clear defini=on
©2014 CloudBees, Inc. All Rights Reserved 21
New Workflow Syntax
22
Production Release Available NOW!
• Jenkins OSS – Workflow 1.0 released December 3
• Beta out since May, with great, engaged feedback • Install Workflow: Aggregator in LTS 1.580.x or a later weekly release
• Jenkins Enterprise by CloudBees – Automa=cally available as of the 14.11 release
23 ©2014 CloudBees, Inc. All Rights Reserved
Demo Time!
©2014 CloudBees, Inc. All Rights Reserved 24
Key Features
• En=re flow is one concise Groovy script – For loops, try-‐finally, fork-‐join …
• Can restart Jenkins while flow is running • Allocate slave nodes and workspaces
– As many as you want, when you want
• Stages throdle concurrency of builds • Human input/approval integrated into flow • Standard project concepts: SCM, ar=facts, plugins
©2014 CloudBees, Inc. All Rights Reserved 25
Groovy DSL vs. Graphical Workflow
• Familiar control flow construc=on • Familiar “tools” for building abstrac=ons
Func=ons, classes, variables, …
• Workflow in version control • As opposed to:
Graphical workflow designer
©2014 CloudBees, Inc. All Rights Reserved 26
Project Setup
• One workflow is defined as a job • Single script for all steps • Build triggers & parameters like regular projects • Each workflow execu=on is a regular Jenkins build displayed in regular Jenkins views
• Graphical visualiza=on of actual build possible Not of visualiza=on job defini=on but of build execu=on
©2014 CloudBees, Inc. All Rights Reserved 27
Non-Sequential Logic
try {} catch {}
©2014 CloudBees, Inc. All Rights Reserved 28
timeout(time: 300, unit: 'SECONDS') { }
Interaction with Humans
©2014 CloudBees, Inc. All Rights Reserved 29
Restartable Build / Checkpoint
©2014 CloudBees, Inc. All Rights Reserved 30
Visualization
©2014 CloudBees, Inc. All Rights Reserved 31
Stages
• Semaphore • Visualiza=on
©2014 CloudBees, Inc. All Rights Reserved 32
Comprehensible Scripts
©2014 CloudBees, Inc. All Rights Reserved 33
Workflow Syntax Card
©2014 CloudBees, Inc. All Rights Reserved 34
Workflow Syntax Card
• stage: Enter a new stage • node: Allocate node • ws: Allocate workspace • parallel: Execute sub-‐workflow in parallel • retry: Retry the body up to N =mes • catchError: Catch error and con=nue • timeout: Execute the body with a =meout • input: Input / human interac=on
©2014 CloudBees, Inc. All Rights Reserved 35
Workflow Syntax Card
• load: Evaluate a Groovy source file into the workflow script • step: General build step • sh: Shell script • bat: Windows batch script
©2014 CloudBees, Inc. All Rights Reserved 36
Workflow Syntax Card
• archive: Archive ar=facts • unarchive: Copy archived ar=fact into the workspace • echo: Print message • dir: Change directory • readFile: Read file from workspace • writeFile: Write file to workspace
©2014 CloudBees, Inc. All Rights Reserved 37
Workflow Syntax Card
• git: Git • svn: Subversion • scm: General SCM • tool: install a tool • build: Build a job
©2014 CloudBees, Inc. All Rights Reserved 38
Workflow Syntax Card
• checkpoint: capture the state of the execu=on so that it can be restarted later
©2014 CloudBees, Inc. All Rights Reserved 39
Possible Futures
©2014 CloudBees, Inc. All Rights Reserved 40
Possible Futures Probably OSS
• More plugin interoperability • Mul=-‐branch project (& SCM API) integra=on • More advanced SCM • In-‐IDE edi=ng support • Concise syntax
©2014 CloudBees, Inc. All Rights Reserved 41
Possible Futures Probably CloudBees Jenkins Enterprise and Operations Center
• More visualiza=ons • Validated merge integra=on • Deployment, incl. blue/green with rollback • Freestyle and/or Build Flow import • Templates integra=on
©2014 CloudBees, Inc. All Rights Reserved 42
Get The Code
• hdps://gist.github.com/cyrille-‐leclerc/0dc73659e6d2a92f014a – workflow.groovy
• hdps://github.com/cyrille-‐leclerc/spring-‐petclinic/
©2014 CloudBees, Inc. All Rights Reserved 43
More Workflow Resources
• Tutorial – hdps://github.com/jenkinsci/workflow-‐plugin/blob/master/TUTORIAL.md
• Jenkins Enterprise by CloudBees Workflow-‐related Func=onality – hdp://jenkins-‐enterprise.cloudbees.com/docs/user-‐guide-‐docs/workflow.html
• More webinars
44 ©2014 CloudBees, Inc. All Rights Reserved
Cyrille Le Clerc Director, Product Management
[email protected] @cyrilleleclerc
Steve Harris SVP, Products
[email protected] @stevengharris
©2014 CloudBees, Inc. All Rights Reserved 45
©2014 CloudBees, Inc. All Rights Reserved 46