1

When my build is successful I get a slack notification, when it fails I do not. Looking at the Drone web UI it looks like it stops once the build fails and the slack plugin is never run.

A successful build results in notify happening:

enter image description here

A failed build does not get to the notify stage:

failed build

The key parts of the .drone.yml are as follows:

  build:
    image: propheris/ruby:2.4.0
    secrets: [gems_password]
    commands:
      - exit 0     

  notify:
    image: plugins/slack
    webhook: https://example.com/hooks/token
    channel: dev
    username: drone
    icon_emoji: drone

I change exit 0 or exit 1 to simulate a successful or failed build.

  • Drone 0.7
  • plugin/slack
Kris
  • 19,188
  • 9
  • 91
  • 111

1 Answers1

3

I've taken a look at the docs and it seems your missing the following line:

when:
    status: [ success, failure ]

The docs state:

Example configuration for success and failure messages:

pipeline:
  slack:
    image: plugins/slack
    webhook: https://hooks.slack.com/services/...
    channel: dev
    when:
      status: [ success, failure ]

You can also add custom messages:

Example configuration with a custom message template:

pipeline:
  slack:
    image: plugins/slack
    webhook: https://hooks.slack.com/services/...
    channel: dev
    template: >
      {{#success build.status}}
        build {{build.number}} succeeded. Good job.
      {{else}}
        build {{build.number}} failed. Fix me please.
      {{/success}}
BugHunterUK
  • 8,346
  • 16
  • 65
  • 121
  • 1
    Scratch that, it seems, it has to be, as indicated in the docs `status: [ success, failure ]` not `status: [success, failure]` as I had. – Kris Nov 02 '17 at 13:37