Jenkins Workflow Webinar - Dec 10, 2014

46
Orchestrating the Continuous Delivery Process in Jenkins with Workflow ©2014 CloudBees, Inc. All Rights Reserved 1

Transcript of Jenkins Workflow Webinar - Dec 10, 2014

Page 1: Jenkins Workflow Webinar - Dec 10, 2014

Orchestrating the Continuous Delivery Process in Jenkins with Workflow

©2014  CloudBees,  Inc.  All  Rights  Reserved   1  

Page 2: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 3: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 4: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 5: Jenkins Workflow Webinar - Dec 10, 2014

Continuous Delivery

©2014  CloudBees,  Inc.  All  Rights  Reserved   5  

Page 6: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 7: Jenkins Workflow Webinar - Dec 10, 2014

Continuous Integration Steps

Con$

nuou

s  Integra$o

n   Source Code

Quality Analysis

Compile &Unit Tests

Binaries

©2014  CloudBees,  Inc.  All  Rights  Reserved   7  

Page 8: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 9: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 10: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 11: Jenkins Workflow Webinar - Dec 10, 2014

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

Page 12: Jenkins Workflow Webinar - Dec 10, 2014

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

Page 13: Jenkins Workflow Webinar - Dec 10, 2014

Jenkins – Puppet Integration

Page 14: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 15: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 16: Jenkins Workflow Webinar - Dec 10, 2014

Most Existing Workflow In Jenkins Today

•  Job  Chaining  

•  Build  Flow  Plugin  

•  Build  Pipeline  Plugin  

•  Build  Delivery  Pipeline  

©2014  CloudBees,  Inc.  All  Rights  Reserved   16  

Page 17: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 18: Jenkins Workflow Webinar - Dec 10, 2014

Jenkins Workflow Engine

©2014  CloudBees,  Inc.  All  Rights  Reserved   18  

Page 19: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 20: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 21: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 22: Jenkins Workflow Webinar - Dec 10, 2014

New Workflow Syntax

22  

Page 23: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 24: Jenkins Workflow Webinar - Dec 10, 2014

Demo Time!

©2014  CloudBees,  Inc.  All  Rights  Reserved   24  

Page 25: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 26: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 27: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 28: Jenkins Workflow Webinar - Dec 10, 2014

Non-Sequential Logic

try {} catch {}

©2014  CloudBees,  Inc.  All  Rights  Reserved   28  

timeout(time: 300, unit: 'SECONDS') { }

Page 29: Jenkins Workflow Webinar - Dec 10, 2014

Interaction with Humans

©2014  CloudBees,  Inc.  All  Rights  Reserved   29  

Page 30: Jenkins Workflow Webinar - Dec 10, 2014

Restartable Build / Checkpoint

©2014  CloudBees,  Inc.  All  Rights  Reserved   30  

Page 31: Jenkins Workflow Webinar - Dec 10, 2014

Visualization

©2014  CloudBees,  Inc.  All  Rights  Reserved   31  

Page 32: Jenkins Workflow Webinar - Dec 10, 2014

Stages

•  Semaphore  •  Visualiza=on  

©2014  CloudBees,  Inc.  All  Rights  Reserved   32  

Page 33: Jenkins Workflow Webinar - Dec 10, 2014

Comprehensible Scripts

©2014  CloudBees,  Inc.  All  Rights  Reserved   33  

Page 34: Jenkins Workflow Webinar - Dec 10, 2014

Workflow Syntax Card

©2014  CloudBees,  Inc.  All  Rights  Reserved   34  

Page 35: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 36: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 37: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 38: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 39: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 40: Jenkins Workflow Webinar - Dec 10, 2014

Possible Futures

©2014  CloudBees,  Inc.  All  Rights  Reserved   40  

Page 41: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 42: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 43: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 44: Jenkins Workflow Webinar - Dec 10, 2014

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  

Page 45: Jenkins Workflow Webinar - Dec 10, 2014

Cyrille Le Clerc Director, Product Management

[email protected] @cyrilleleclerc

Steve Harris SVP, Products

[email protected] @stevengharris

©2014  CloudBees,  Inc.  All  Rights  Reserved   45  

Page 46: Jenkins Workflow Webinar - Dec 10, 2014

©2014  CloudBees,  Inc.  All  Rights  Reserved   46