Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Continuous Deployment with Jenkins Pipelines

Continuous Deployment with Jenkins Pipelines

DevOps Bergen meetup where I talk about Continuous Integration and Deployment with Jenkins Pipelines.

Hans Kristian Flaatten

August 01, 2017
Tweet

More Decks by Hans Kristian Flaatten

Other Decks in Technology

Transcript

  1. ! 3 About me • Hans Kristian Flaatten • Married

    and two boys • Informatics @ NTNU • Platform Engineer • DevOps Practice Lead • Node.js Foundation Member
  2. !  CI / CD  Git  Team 

     Container Platform  Monitorering  Errors  Logging  Chat App Platform 2017
  3. ! 5

  4. ! Agenda • Continuous Integration (CI) • The CI Server

    • Jenkins CI • Continuous Deployment (CD) • Continuous Delivery • Infrastructure as Code • Jenkins Pipelines • DEMO
  5. ! 8 Continuous Integration Integrating code back to a shared

    mainline • Automate build & test • Ensure reproducibility • Detect errors early • Improve quality • Reduce cost
  6. ! 13 The CI Server 1. Fetch code from source

    control 2. Build and test the software 3. Notify on success/failure
  7. ! 14 The CI Server (cont) • General purpose •

    Language, framework & tooling • Good integrations • Source control & team communication • Support complex build pipelines • Store artefacts • Run deployment • Be efficient
  8. ! 17 Jenkins CI • General purpose automation server •

    Free and open source • Works on any plattform • Released in 2005 • Sponsored by CloudBees • The largest CI plugin system https://jenkins.io/
  9. ! 18 The good, the bad & the ugly •

    You can do anything • You can do ANYTHING • Customisability vs. ease of use • It is still a JAVA application
  10. ! 19 Some terminology • Job - a unit of

    work for a project • Pipeline • View - user defined collection of jobs or a workflow • Master - the central Jenkins master, does job scheduling • Agent - executes one or more jobs within slots (executors) • Workspace - the working area where a job is carried out
  11. ! 22 Traditional Jenkins Jobs ! " # # !

    # " # Job Config Secret $ $ Code " Jenkins SCM "
  12. ! 23 Traditional Jenkins Jobs • Web UI centric •

    All jobs must be configured manually • Overhead for multiple (smaller) projects • Source code and job must be kept in sync • Chaining multiple jobs becomes messy • Build • Test • Deploy
  13. ! 33 New Jenkins Pipelines • One job per repository

    • Jenkins jobs as code • Jenkinsfile in source code repository • Always in sync with the code • All changes are logged • Written in Groovy • Declarative syntax • Domain Specific Language (DSL) • Extended by Shared Libraries
  14. ! 34 Pipeline Terms • Node - where to run

    a set to stages • Stage - a single stage in a Pipeline • Step - a single task to be executed
  15. ! 35 Jenkinsfile node('any') { stage('Build') { sh 'make' //

    this is a step } stage('Test') { ... } stage('Deploy') { ... } }
  16. ! 36 Wait for user input node('any') { stage('Build') {

    sh 'make' } stage('Test') { ... } stage('Deploy to test') { ... } input('Ready for production?') stage('Deploy to prod') { ... } }
  17. ! 38 Challenges • Testing Jenkinsfiles • Use the online

    editor • Groovy Standbox • Repetition between projects • Make shared libraries • Wrapping errors in try/catch • Fixed in newer declarative pipelines
  18. ! 41 Jenkins + Docker Jenkins " # Jenkinsfile #

    # Stages 1 2 3 install build test