Fastlane is an excellent and essential tool for app developers to automate many of the otherwise time-consuming, tedious tasks. With a simple terminal command you can make run all the steps from compiling and packaging an app, to uploading it to the app stores, updating release notes, uploading the change log on a web page, to basically whatever else you can imagine. These tasks can take a while to run, so you want to know early when they fail.

How this looks for me is that I usually use a headless Mac Mini for running builds. I like triggering fastlane tasks from my iPad using Screens (or Blink). I’ve set this up, so that I get a push notification when there’s a fastlane failure. The notification tells me the error and tapping it opens Screens connecting to that build machine. I can then fix the error and re-trigger the run. I love it.

It’s easy to setup and consists of two components:

1. IFTTT Applet

Firstly you’ll need to create an IFTTT applet using the iOS app.

Use the Webhook as the trigger, I’ve set mine to wait for a fastlane_error event.

Use the rich notification as the action. My text here is Lane: {Value1}. Machine: {Value3}. Error: {Value2}. And I’ve also added a link, which is using Screens’ URL scheme, so that tapping the notification will open screens and immediately connect me to the build machine. For that I’ve set the URL to screens://{Value2}.

2. Your Fastfile

At the end of your Fastfile you can add an error handler to your platform block. Mine looks like this, using the built-in ifttt action:

platform :ios do
  ...
  
  error do |lane, exception|
    require 'socket'
    ifttt(
      api_key: ENV['IFTTT_API_KEY'],
      event_name: "fastlane_error",
      value1: "#{lane}",
      value2: "#{exception}",
      value3: Socket.gethostname
    )
  end
end

This will add the values as the IFTTT applet expects them, notably dynamically inserting the build machine’s host name.

For the API key, I’m using an environment variable, so that I only get notifications for fastlane builds that I trigger, and not for those by other team members. We have a .env.default file for that, which is not committed to our git repo. Just add a line IFTTT_API_KEY=... to that file with your IFTTT API key, which you get from the Webhooks page by clicking the “Documentation” link.

Now you’re all set. Trigger a run and enjoy the errors.