Pipeline for molecule test

pipeline:
  molecule:
    image: python:alpine
    commands:
      - pip install ansible
      - pip install docker
      - pip install molecule
      - ansible --version
      - molecule --version
      - docker -v
      - molecule test

CLI

Install 0.7.0

curl -L https://github.com/drone/drone-cli/releases/download/v0.7.0/drone_linux_amd64.tar.gz | tar zx
sudo install -t /usr/local/bin drone

Launch a build

drone -s http://test.tld -t '$DRONE_SECRET' build start rgarrigue/ansible-role-yum-repositories

Drone secrets

drone global secret add DOCKER_USERNAME andrew  
drone global secret add DOCKER_PASSWORD password  
drone global secret add DOCKER_EMAIL email  

Services

Services are like the database you need for tests. Like the MySQL database below will be available at db:3306 for tests.

services:
  db:
    image: mysql
    environment:
      - MYSQL_USER=myuser
      - MYSQL_PASSWORD=mypwd
      - MYSQL_DATABASE=myapp

Plugins snippets

Most of this is C/C from official doc and plugins doc with interesting options. Note, there are more plugins (?) in the github repository

Webhook

notify:
  webhook:
    urls:
      - https://your.webhook/...
      - https://your.other.webhook/...
    headers:
      - "Authorization=pa55word"

Trigger

Trigger other drone build after this one. Token may come from drone's secret secrets: [ downstream_token ]

pipeline:
  trigger:
    image: plugins/downstream
    server: https://drone.example.com
    token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
    fork: true
    repositories:
      - octocat/Hello-World@develop
      - octocat/Spoon-Knife

SSH

Private key key_path: ./deploy/key.pem can also be used as replacement for password.

pipeline:
  ssh:
    image: appleboy/drone-ssh
    host:
+    - foo.com
+    - bar.com
    username: root
    password: 1234
    port: 22
    script:
      - echo hello
      - echo world
    when:
      status: success

Rsync

pipeline:
  deploy:
    image: drillster/drone-rsync
    hosts: [ "server-prod1", "server-prod2" ]
    key: "-----BEGIN RSA PRIVATE KEY----- ...."
    source: ./target
    target: ~/packages
    include: [ "app.jar", "app.jar.md5" ]
    exclude: [ "**.*" ]
    script:
      - cd ~/packages
      - md5sum -c app.jar.md5

Git clone

clone:
  git:
    image: plugins/git
    depth: 50

Email

recipients_only avoid sending to build owner too.

pipeline:
  notify:
    image: drillster/drone-email
    environment:
      - DOCKER_LAUNCH_DEBUG=true
    host: smtp.mailgun.org
    from: drone@domain.org
    subject: >
      [{{ build.status }}]
      {{ repo.owner }}/{{ repo.name }}
    template: >
      https://git.io/vgvPz
    when:
      status: [ success, changed, failure ]

  notify:
    image: drillster/drone-email
    host: smtp.some-server.com
    skip_verify: true
    username: foo
    password: bar
    from: drone@your-domain.com
    recipients: [ the-admin@your-domain.com, octocat@your-domain.com ]
    recipients_only: true
    when:
      status: [ changed, failure ]

Docker publishing

Build a Docker and publish to a Registry. Inline username / password can be replaced by a drone secret, like secrets: [ docker_username, docker_password ]

pipeline:
  docker:
    image: plugins/docker
    username: kevinbacon
    password: pa55word
    email: kevin.bacon@mail.com
    repo: foo/bar
    tags: latest
    build_args:
      - HTTP_PROXY=http://yourproxy.com

Volume caching

For faster build, but requires a Trusted flag for this repository.

pipeline:
  restore-cache:
    image: drillster/drone-volume-cache
    restore: true
    mount:
      - ./node_modules
    volumes:
      - /tmp/cache:/cache

  build:
    image: node
    commands:
      - npm install

  rebuild-cache:
    image: drillster/drone-volume-cache
    rebuild: true
    mount:
      - ./node_modules
    volumes:
      - /tmp/cache:/cache