GithubHelp home page GithubHelp logo

nulogy / buildkite-failed-builds-notifier Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joscha/buildkite-failed-builds-notifier

0.0 3.0 0.0 75 KB

A Buildkite webhook that sends out an email to people that potentially have failed a build

JavaScript 100.00%

buildkite-failed-builds-notifier's Introduction

Bilbo, the buildkite failed builds notifier

A Buildkite webhook that sends out an email to people that potentially have failed a build.

It looks like this:

inbox

details

Failures stack:

stacked

until the build passes, at which the culprits are reset.

It uses the Buildkite webhooks and webtask.io.

Assumptions

  • The culprits are stored per pipeline, so only one branch can be used for each pipeline, e.g. master. If you want to track culprits between builds in multiple branches, you need to set up separate webtasks.
  • Only the current person triggering the Buildkite pipeline will be notified, assuming all others have been notified in the builds before. This will not work for commits which use [skip ci] or [ci skip].
  • Pipelines are tracked with their organization, so you can use one webtask with multiple organizations, even if you have pipelines with the same name.
  • The commit shas, the commit message, the email and name of the triggering person and some other data is stored in the webtask storage. For what is stored, see here.
  • TODO: in case an older build on the same pipeline that is passed after failure (by reruns for example), it removes the recorded failed state currently. Ideally the state would be kept, from the failing build upwards.

Installation

Via wt-cli:

wt create https://raw.githubusercontent.com/joscha/buildkite-failed-builds-notifier/master/failed-builds-notification.js \
          --name bilbo \
          --secret SENDGRID_API_TOKEN=<SENDGRID_API_TOKEN> \
          --secret MANDRILL_API_KEY=<MANDRILL_API_KEY> \
          --secret BUILDKITE_TOKEN=<BUILDKITE_TOKEN> \
          --secret [email protected] \
          --dependency [email protected] \
          --dependency [email protected]

You need either SENDGRID_API_TOKEN or MANDRILL_API_KEY. If both given, Mandrill will be preferred.

Needed modules

wt modules add [email protected]
wt modules add [email protected]
wt modules add [email protected]

Needed secrets:

  • Either SENDGRID_API_TOKEN: Create a new API token and give it full access for Mail Send: Mail Send

  • Or: MANDRILL_API_KEY: Create a new API key

  • BUILDKITE_TOKEN: from your Buildkite webhook settings: Token

  • SENDER_EMAIL_ADDRESS: The email address that is used by the email provider to generate the build fail emails.

Email settings

Sendgrid

Disable click tracking

Click tracking

otherwise the URLs in the plain text email become really long.

Enable plain content

Plain Content

otherwise the plain text will be automatically converted to HTML by sendgrid and the formatting will be off.

Buildkite webhook settings

Enable the ping and build.finished events:

Events

Test

You can test the webtask with this snippet:

{
  "event": "build.finished",
  "build": {
    "web_url": "https://buildkite.com/some-org/some-pipeline/builds/1",
    "number": 1,
    "state": "failed",
    "message": "Some build message",
    "commit": "c0ffeec0ffeec0ffeec0ffeec0ffeec0ffeec0ff",
    "creator": {
      "name": "Mister Test",
      "email": "[email protected]"
    }
  },
  "pipeline": {
    "name": "Some pipeline",
    "url": "https://api.buildkite.com/v2/organizations/some-org/pipelines/some-pipeline",
    "slug": "some-pipeline",
    "repository": "[email protected]:some/repo.git"
  }
}

Important: Be sure to replace [email protected] with your own email, to actually receive anything.

Don't forget to send this as JSON (Content-Type: application/json) and also pass your Buildkite token via the X-Buildkite-Token header. You can replace "state": "failed" with "state": "passed" to simulate a passed build run.

buildkite-failed-builds-notifier's People

Contributors

joscha avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.