Web Hooks: Integrating Kiln with Other Services


Follow

Overview

Kiln administrators can add webhooks as a useful integration point between Kiln and any number of other services.
This article provides a detailed overview of the components of Built-in webhooks, Custom webhooks, and Testing webhooks.

Following is the glossary for a quick overview of the article topics:


Information


1.Built-in Webhooks

Following is a list of pre-built webhooks that can be used under the Kiln user menu > Kiln Administration > Web Hooks:

  1. In the Web Hooks configuration screen, in addition to classic webhooks (called “A custom hook”), you can select the service you would like to target with your webhook, and Kiln tells you exactly what you need to set up the hook.
  2. In all cases, we have tried to make it as easy to configure as possible.
    For example, if you want HipChat or Campfire integration, a dropdown of what rooms you can submit to is automatically provided.
    We likewise provide a list of your build configurations when you are integrating with TeamCity.
    You can pick your service, then follow the simple instructions to connect Kiln.

1.1 Chat & IM

  • Kiln can post updates on the progress of your source code right into your chat environment, making it really easy to keep your support staff up to date on what you are up to.

    Kiln in HipChat

  • Kiln only posts the first few changesets, so no worries about getting completely crushed in your chat room with a 2000-changeset push.


1.2 Build & CI

  • The TeamCity integration allows you to tell TeamCity when to build based on when you push.
  • No more constant polling your Kiln installation; Kiln simply tells TeamCity when it needs to get built.
  • Like all webhooks, you can tie TeamCity to any arbitrary collection of repositories, so having a product that is built from several different repositories is not being an issue.

NOTE: The TeamCity integration does not yet support TeamCity v2017.1 or later.


1.3 Project Management

  • You can use Kiln without FogBugz and you can also integrate Kiln with other bug trackers. Kiln now directly supports Pivotal Tracker.

    benj.png

  • Kiln your Pivotal API token, then use your normal Pivotal commit syntax (e.g., [Delivers #123] automatically marks story #123 as delivered), and Kiln adds links to your changesets to the relevant stories.


1.4 Cloud Application Hosting

Kiln now offers simple deployment to AppHarbor and Windows Azure.

  • For AppHarbor, you can use the Build URL provided for your app (see the bottom of the menu):

    Screen Shot 2013-07-30 at 12.26.40 PM

  • To set up Azure integration, you need to set up local Git publishing.
    Azure then provides you with a deployment username and password (in addition to your repository URL), which you can enter on the webhook form.

These are just the first few baked-in web hooks we are providing.


Custom Webhooks

  1. To configure a custom webhook, choose the URL Kiln should hit and which repositories should fire the hook.
  2. Then, every time these repositories receive a push, information about the push and its changesets get  POST’ed to the URL.
  3. The data POST’ed is a JSON (JavaScript Object Notation) payload, and the data is accessible via the “payload” POST variable. Thus, if you are in .NET land, you can access the JSON payload like so:
string s =Request["payload"];
  1. …and string s will contain a JSON string of the following format:
{
  "commits":[
    {
      "author":"Testuser <testuser@example.com>", 
      "branch":"default", 
      "id":"16265aef917cfe137e250c4f71a4a77ff4ad0974", 
      "message":"This thing is taking forever", 
      "revision":14, 
      "timestamp":"3\/23\/2010 3:42:42 PM", 
      "url":"http:\/\/test.kilnhg.com\/Repo\/Personal\/Playground\/DNForever\/History\/16265aef917cfe137e250c4f71a4a77ff4ad0974",
      "tags":[
        "tip"
      ]
    }, 
    {
      "author":"Testuser <testuser@example.com>", 
      "branch":"default", 
      "id":"a077d19afed224dc7c46dc535d5f7e90546ed5bd", 
      "message":"This version is now shippable", 
      "revision":15, 
      "timestamp":"3\/23\/2010 3:42:46 PM", 
      "url":"http:\/\/test.kilnhg.com\/Repo\/Personal\/Playground\/DNForever\/History\/a077d19afed224dc7c46dc535d5f7e90546ed5bd",
      "tags":[]
    }
  ], 
  "pusher":{
    "email":"testuser@example.com",
    "fullName":"Testuser"
  },
  "repository":{
    "central":true,
    "description":"Picking up where the others left off", 
    "id":1,
    "name":"DNForever", 
    "url":"http:\/\/test.kilnhg.com\/Repo\/Personal\/Playground\/DNForever"
  }}
  1. You can then parse this and use, however, necessary in your continuous integration server or any piece of software that needs to know when Kiln receives a push.
  2. The repository.id key is the repository’s ixRepo, suitable for sending to the Kiln API.

NOTE: The timestamp for commits are in UTC.

IMPORTANT! Please keep in mind that this data will be sent regardless of your Kiln repository’s permissions settings.

 

Testing Webhooks

Here is a quick and easy way to test whether or not your webhooks are firing:

  1. Go to http://requestb.in/ (or the login-based https://www.runscope.com/)
  2. Click “Make a requestbin” to create a requestbin for yourself.
  3. Create a new webhook in Kiln that points to your postbin URL.
  4. Push some of the codes to one of your Kiln repositories.
    NOTE: The data about this push is publicly available, so do not push anything sensitive.
  5. If everything worked properly, your postbin URL now displays all of the data sent from Kiln to postbin.org by the webhook, and it looks very similar to the example webhook data above.