Drone

Drone is a CI/CD platform built on Docker and written in Go.

Creating Pipeline

Drone pipeline are written in .drone.yml file in the root of the repository.

  • Pipelines are event based, which can be triggered via push, pull_request, tag and deployment events
pipeline:
  backend:
    image: golang
    commands:
      - go get
      - go build
      - go test

  frontend:
    image: node:6
    commands:
      - npm install
      - npm test

  notify:
    image: plugins/slack
    channel: developers
    username: drone

Images

Drone executes your build inside an ephemeral Docker Image, which means you don’t have to setup or install any repository dependencies.

Cloning

Drone automatically clones your repository into a local volume that is mounted into each Docker container.

Commands

Drone mounts the workspace into your build container (Defined Image) and executes bash commands inside your build container, using the root of your repository as the working directory.

Services

Drone supports launching service containers as part of the build process. This can be very helpful when your unit tests require database access etc.

Plugins

Drone supports publish, deployments and notification capabilities through external plugins.

Running Drone Locally

drone exec

Drone Secrets

Repo Level Secrets

# Create Value Secret (Concealed)
drone secret add --conceal <repo_path> <secretName> <secretValue>

# Create Value Secret
drone secret add <repo_path> <secretName> <secretValue>

# Create File Secret
drone secret add <repo_path> <secretName> @<filePath>

# View Secret for a Repo
drone secret ls <repo_path>

Org Level Secrets

# Create Org Level Secret (Concealed)
drone org secret add --conceal <org> <secretName> <secretPass>

# Create Org Level Secret
drone org secret add <org> <secretName> <secretPass>

# Create Org Level File Secret
drone org secret add <org> <secretName> @<filePath>

Using Secrets in Pipeline

pipeline:
  docker:
    image: plugins/docker
-   username: ${DOCKER_USERNAME}
-   password: ${DOCKER_PASSWORD}
+   secrets: [ docker_username, docker_password ]