sbt plugin to trigger IFTTT webhook events
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
project
src
.scalafmt.conf
README.md
build.sbt
sbt-logo.png

README.md

sbt-ifttt

Download

sbt-ifttt is an sbt plugin to trigger an IFTTT webhook after the tasks

  • compile (via running nCompile)
  • test (via nTest)
  • assembly (via nAssembly)

Requirements

  • sbt (version >= 0.13.5 should do it, although I have only tried with 1.1.4)
  • sbt-assembly plugin (to make nAssembly work)

Usage

Install by adding

resolvers += Resolver.bintrayIvyRepo("rberenguel", "sbt-plugins")

and

addSbtPlugin("com.rberenguel" % "sbt-ifttt" % "0.1.0")

either at project or global level (more details below).

The actions defined above will trigger the webhook passing:

  • Value 1: sbt (it's used as title)
  • Value 2: message (task has finished or task has failed)
  • Value 3: sbt icon (can appear in notifications)

Assuming you have an account (it's free), you can create a webhook applet in IFTTT here:

  1. Click on this and search for webhook
  2. Choose Receive a web request
  3. Choose the event name (I have command_line_notify since I use it for other events)
  4. Choose the action service. In my case, I have a notification, that triggers my watch

You can choose whatever available as a service. Switch your lights' colour, send you an email... Anything available via IFTTT as an action service.

To configure the plugin, you will need the event name (in step 3 above) and your access key. You can find your access key in the webhooks page by pressing Documentation (top right).

You can build the plugin locally by cloning this repository and running sbt publishLocal. As soon as I figured how to publish it I will do it :)

Then, add it to a project by adding

addSbtPlugin("com.rberenguel" % "sbt-ifttt" % "0.1-SNAPSHOT")

to project/plugins.sbt and activate it by adding

project
  .enablePlugins(SbtIFTTT)
  .settings(iftttPrintOnly := false,
            iftttKey := "YOUR_KEY",
            iftttEvent := "YOUR_EVENT")

Alternatively you can add it as a global plugin by adding

addSbtPlugin("com.rberenguel" % "sbt-ifttt" % "0.1-SNAPSHOT")

to any file ending in .sbt in ~/.sbt/1.0/plugins/ and adding the configuration

iftttPrintOnly := false
iftttKey := "YOUR_KEY"
iftttEvent := "YOUR_EVENT"

to any file ending in .sbt (custom is global.sbt) in ~/.sbt/1.0/.

Why

This was inspired by the following tweet by Rúnar Bjarnason:

Just another day at the office. pic.twitter.com/1iaPzIjQYj

— Rúnar (@runarorama) April 23, 2018

At the time I was running very long computations with Spark, and wanted to be notified on my watch when the cluster was finished and ready for the next step. Long sbt builds/assembly/test only seemed a natural extension once I got IFTTT working, and since I had never written a plugin, this was as good a first time as any.

Caveats

This is the first time I tried to write a plugin, so it can probably be improved in a million ways. Help me with a PR!