59
Madrid Drone CI Kickstarting your project with Drone Kickstarting your project with Drone

Drone Continuous Integration

Embed Size (px)

Citation preview

Madrid Drone CI

Kickstarting your project with DroneKickstarting your

project with Drone

AgendaAgenda

What is CI? Differences with Cd & CD Why should I implement CI? How to implement CI? Virtualization & Containerization Drone Hands on Drone Drone vs Jenkins

#MadDroneCI@dcerecedo

[email protected]

What?What?

Integration

Continuous ~

Integration

DeliveryContinuous ~

Integration

Delivery

Deployment

Continuous ~

Why?Why?

Reduced Cost

Reduced Cost & Risk

Reduced Cost & RiskGreater Productivity

Reduced Cost & RiskGreater ProductivityContinuous Improvement

Reduced Cost & RiskGreater ProductivityContinuous ImprovementTeam Confidence

Reduced Cost & RiskGreater ProductivityContinuous ImprovementTeam Confidence & Reputation

How?How?

Single source repository

Automated build

Self testing build

Self documenting build

Developer owned build

Fast build

Test in production clone

Report on build status

Traceability from binaries to source

Keep binaries accessible

VirtualizationVirtualization

bins & libs bins & libs bins & libs

Guest OS Guest OS Guest OS

Hypervisor

Host Operating System

Hardware

APP1 APP2 APP3

Guest OS Guest OS

Docker Engine

Host Operating System

Hardware

bins & libs bins & libs bins & libs

APP1 APP2 APP3

bins & libs bins & libs bins & libs

Guest OS Guest OS Guest OS

Hypervisor

Host Operating System

Hardware

APP1 APP2 APP3

Guest OS Guest OS

Docker Engine

Host Operating System

Hardware

bins & libs bins & libs bins & libs

APP1 APP2 APP3

DroneDrone

One server, multiple agents

Everything is a Docker container

Sample 1Sample 1

Understand Drone Login A glimpse to the Dashboard Configuring the Drone CLI

Sample 2Sample 2

Showcase the sample app Create a Meetup, a Location and an Event

Run some testsStatically analyze codeVerify quality gatesBuild binariesDeploy binariesBuild Docker imageDeploy containerNotify results

A typical pipeline

Run some testsStatically analyze codeVerify quality gatesBuild binariesDeploy binariesBuild Docker imageDeploy containerNotify results

Our sample pipeline

Sample 3Sample 3

Activate a repo Review the simplest Drone pipeline Generate a trigger via git push Show build logs Show how the workspace is mounted in build steps

A pipeline is an ordered list of build steps

Plugin steps or custom steps

The clone step is implicit and is always first

A workspace is shared across all steps

Sample 4Sample 4

Base pipeline: executing tests with in-memory database

Testing a build

Sample 5Sample 5

Using services The problem with credentials. Managing secrets Base pipeline: executing tests against a real database

Services are dependencies of the build

Drone Workspace

Git Container

Step 1 Container

Step N Container

Drone Environment Variables Drone Secret Variables

Drone Service Container 1

Docker Networking

Docker Networking

Docker Networking

Docker volume mount

Docker volume mount

Docker volume mount

Steps can read Drone envars & Drone secrets

Drone Workspace

Git Container

Step 1 Container

Step N Container

Drone Environment Variables Drone Secret Variables

Drone Service Container 1

Docker Networking

Docker Networking

Docker Networking

Docker volume mount

Docker volume mount

Docker volume mount

CI=drone DRONE=true DRONE_ARCH DRONE_REPO DRONE_REPO_OWNER DRONE_REPO_NAME DRONE_REPO_SCM DRONE_REPO_LINK DRONE_REPO_AVATAR DRONE_REPO_BRANCH DRONE_REPO_PRIVATE DRONE_REPO_TRUSTED DRONE_REMOTE_URL DRONE_COMMIT_SHA DRONE_COMMIT_REF DRONE_COMMIT_BRANCH DRONE_COMMIT_LINK DRONE_COMMIT_MESSAGE DRONE_COMMIT_AUTHOR DRONE_COMMIT_AUTHOR_EMAIL DRONE_COMMIT_AUTHOR_AVATAR

DRONE_BUILD_NUMBER DRONE_BUILD_EVENT DRONE_BUILD_STATUS DRONE_BUILD_LINK DRONE_BUILD_CREATED DRONE_BUILD_STARTED DRONE_BUILD_FINISHED DRONE_PREV_BUILD_STATUS DRONE_PREV_BUILD_NUMBER DRONE_PREV_COMMIT_SHA DRONE_JOB_NUMBER DRONE_JOB_STATUS DRONE_JOB_EXIT_CODE DRONE_JOB_STARTED DRONE_JOB_FINISHED DRONE_YAML_SIGNED DRONE_YAML_VERIFIED DRONE_BRANCH DRONE_COMMIT DRONE_TAG DRONE_PULL_REQUEST DRONE_DEPLOY_TO

Sample 6Sample 6

Using plugins Caching between build steps Caching between builds Conditional execution

Inter-step caching

Inter-build caching

Inter-build caching

when: branch:

include: [ master, release/* ] exclude: [ release/1.0.0, release/1.1.* ]

event: [push, pull_request, tag, deployment] status: [ failure, success, changed ] platform: [ linux/*, windows/amd64 ] environment: production

Sample 7Sample 7

Developing plugins Structure of a plugin Building a plugin to check Sonar quality gates

Run some testsStatically analyze codeVerify quality gatesBuild binariesDeploy binariesBuild Docker imageDeploy containerNotify results

Our sample pipeline

Sample 8Sample 8

Sending notifications

Drone ModelDrone Model

Drone vs JenkinsDrone vs Jenkins

Developer owned vs Sysadmin owned Local build testing vs No testing Container centric vs Supports containers Extensible plugin model vs Hard to code plugins Native security vs Ad hoc security Native matrix builds vs Plugin matrix builds Trigger upstream/downstream builds via plugin

Containers from scratch - https://ericchiang.github.io/post/containers-from-scratch/

Docker – https://docker.io Drone documentation – https://readme.drone.io Drone gitter channel – https://gitter.im/drone/drone Software costs - https://www.linkedin.com/post/edit/hidden-cost-speed-

statically-vs-dynamically-typed-daniel-cerecedo

ReferencesReferences

Thanks