and blue ocean with jenkins pipeline zero to continuous ... · deploying to aws/azure deploying to...

46
Zero to Continuous Delivery with Jenkins Pipeline and Blue Ocean Liam Newman

Upload: vuongkhanh

Post on 28-Jul-2018

220 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Zero to Continuous Delivery with Jenkins Pipelineand Blue OceanLiam Newman

Page 2: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Introduction

Page 3: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Introduction

● Liam Newman

○ CI/CD Practitioner

○ Jenkins Contributor

○ Word Engineer

● @bitwiseman

[email protected]

Page 4: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Continuous Delivery

Page 5: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Jenkins Pipeline

Page 6: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Jenkins Pipeline

● Pipeline as Code

○ Capture the entire continuous delivery process

○ Check a Jenkinsfile into your source repo

● jenkins.io/doc/book/pipeline

Page 7: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Blue Ocean

Page 8: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean
Page 9: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean
Page 10: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean
Page 11: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Blue Ocean

docker run -p 8080:8080 -u root \

-v /var/run/docker.sock:/var/run/docker.sock \

jenkinsci/blueocean

Page 12: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean
Page 13: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Zero

Page 14: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

A basic Java application

● bitwise-jenkins/jhipster-sample-app

● Tools

○ Maven

○ Node / Gulp

○ Gatling

○ Docker

Page 15: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Planning the pipeline

Page 16: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Planning the pipeline

● Stages desired:

○ Build

○ Test

■ Unit

■ Performance

■ Front-end

○ Static Analysis

○ Deployment

Page 17: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Blue Ocean Pipeline Editor

Page 18: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Build

Page 19: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Build

● Don't reinvent your build system in Jenkins Pipeline

○ Think of Pipeline as glue

● Goal:

○ Perform a reproducible build

○ Create an artifact which can used later

■ To run tests against

■ To deploy to an environment

● In this case, we're using Maven.

Page 20: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Build

pipeline {

agent any

stages {

stage('Build') {

steps {

sh 'mvn'

}

}

}

}

Page 21: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Build

stage('Build') {

agent {

docker {

image 'maven:3-alpine'

args '-v /root/.m2:/root/.m2'

}

}

/* .. */

}

Page 22: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Build

stage('Build') {

/* .. */

steps {

sh './mvnw -B clean package'

stash name: 'war', includes: 'target'

}

}

Page 23: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Test

Page 24: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Test

pipeline {

agent any

stages {

stage('Backend Unit Test') {

steps {

sh './mvnw -B test'

}

}

}

}

Page 25: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Test

stage('Backend Unit Test') {

agent {

docker {

image 'maven:3-alpine'

args '-v /root/.m2:/root/.m2'

}

}

/* .. */

}

Page 26: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Test

stage('Backend Unit Test') {

/* .. */

steps { unstash 'war' sh './mvnw -B test' junit '**/surefire-reports/**/*.xml'

}

}

Page 27: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Test

stage('Backend Performance Test') {

/* .. */

steps { unstash 'war' sh './mvnw -B gatling:execute'

}

}

Page 28: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Test

stage('Backend') {

steps {

parallel( 'Unit' : { unstash 'war' sh './mvnw -B test' junit '**/surefire-reports/**/*.xml' }, 'Performance' : { unstash 'war' sh './mvnw -B gatling:execute' }) }

}

}

Page 29: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Test

stage('Frontend Test') {

agent { docker 'node:alpine' }

steps {

sh 'yarn install'

sh 'yarn global add gulp-cli'

sh 'gulp test'

}

}

Page 30: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Analyze

Page 31: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Build

pipeline {

agent any

stages {

stage('Analyze') {

}

}

}

Page 32: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Analyze

● Static analysis

● Code coverage checks

● Quality scanning

○ FindBugs

○ PMD

○ etc

jenkins.io/blog/2017/04/18/continuousdelivery-devops-sona

rqube/

Page 33: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Deploy

Page 34: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Deploy

● Don't reinvent your deployment system in Jenkins

PIpeline

○ Think of Pipeline as glue

● "Deployment" may have different meanings

○ Deploying to AWS/Azure

○ Deploying to a physical datacenter

○ Uploading to an app store

○ Uploading to an internal artifact server

Page 35: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Deploy

pipeline {

agent any

stages {

stage('Deploy') {

}

}

}

Page 36: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Deploy

stage('Deploy') {

steps {

sh './deploy.sh'

}

}

Page 37: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Build

Page 38: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Test

Page 39: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Deploy

Page 40: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Other considerations

Page 41: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Notifications

● Feedback to the team is a key part of continuous delivery

● Jenkins Pipeline can be used for:

○ Sending email

○ Sending messages to:

■ HipChat

■ Slack

○ Updating JIRA tickets

jenkins.io/node/tags/notifications/

Page 42: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Manual Promotion

stage('Deploy') {

steps {

input message: 'Deploy to production?',

ok: 'Fire zee missiles!'

sh './deploy.sh'

}

}

Page 43: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Manual Promotion

Page 44: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Zero to Continuous Deliverywith Jenkins Pipeline

and Blue Ocean

Page 45: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Questions?

Page 46: and Blue Ocean with Jenkins Pipeline Zero to Continuous ... · Deploying to AWS/Azure Deploying to a physical datacenter Uploading to an app store ... jenkins.io/projects/blueocean

Resources

● jenkins.io/doc/book/pipeline

● jenkins.io/projects/blueocean

● Docker containers

○ jenkinsci/jenkins:lts-alpine

○ jenkinsci/blueocean

[email protected]