skeleton-drone

Explore a basic .Drone CI pipeline skeleton for automating your Continuous Integration and Continuous Deployment workflows. Learn about triggers, platforms, workspaces, and steps.

.Drone CI Pipeline Skeleton

This page provides a foundational skeleton for a Drone CI pipeline, designed to help developers quickly set up and automate their Continuous Integration and Continuous Deployment (CI/CD) workflows. Drone CI is a powerful, container-native CI/CD platform that leverages a simple YAML syntax to define pipelines.

Drone CI Pipeline Configuration

The following YAML configuration outlines a basic Drone pipeline. It includes essential sections such as kind, type, name, trigger, platform, workspace, and steps. This skeleton is a starting point for building more complex pipelines tailored to specific project needs.

Pipeline Triggers and Events

The trigger section defines when the pipeline should run. In this example, the pipeline is configured to execute on push events to the master branch. This ensures that code changes merged into the main branch automatically initiate the build and deployment process.

Platform and Workspace Setup

The platform specifies the operating system and architecture for the pipeline execution environment, set here to linux/amd64. The workspace defines the directory within the container where the source code will be checked out, typically /drone/src.

Pipeline Steps and Execution

The steps array contains a sequence of commands or container images to be executed. This skeleton includes a greeting step using a busybox image to print a simple message, and conditional steps (send-success and send-failure) that execute based on the build's final status. These conditional steps are useful for sending notifications or performing cleanup actions.

For more advanced configurations and detailed documentation, refer to the official Drone CI resources:

---
# https://docs.drone.io/pipeline/docker/syntax/trigger/
# https://docs.drone.io/pipeline/docker/syntax/platform/
# https://docs.drone.io/pipeline/docker/syntax/workspace/
# https://docs.drone.io/pipeline/docker/syntax/steps/
# http://plugins.drone.io/drone-plugins/drone-webhook/
# https://github.com/drone-plugins/drone-webhook

kind: pipeline
type: docker
name: default

trigger:
  branch:
    - master
  event:
    - push

platform:
  os: linux
  arch: amd64

workspace:
  path: /drone/src

steps:
  - name: greeting
    image: busybox
    environment:
      OWNER: Ruan
    commands:
      - echo "Hi $OWNER"

  - name: send-success
    image: busybox
    when:
      status: [ success ]
    commands:
      - echo "build succeeded"

  - name: send-failure
    image: busybox
    when:
      status: [ failure ]
    commands:
      - echo "build failed"