Classic Webhooks Integration

What are web hooks?

Be sure to check out our newer option, the modular web hooks integration. The classic web hook integration only supports Git pushes and SVN commits, where as the modular web hooks integration supports both of those and much more (deployments, comments, branches etc).

Web hooks allow you to customize, extend and integrate the web applications you use with anything else you can access programmatically. To web developers, web hooks are a simple design pattern that only require the ability to make web requests and to store some extra data about users. To users, web hooks are a way to get events and data in realtime from their web applications.

By using web hooks on your Beanstalk repository, you can get information about each commit to your Beanstalk repository.

How to setup integration

In order to integrate Web hooks with Beanstalk, you need to enable Web hooks integration within your repository. To do this, go to your Repository, then Settings → Integration → Web hooks. To get started with the setup, click on Web hooks icon, and then on Activate integration button inside the page. 

After clicking on the Activate integration button, you will need to enter Web Hook URL. Beanstalk will request this URL with POST data every time you commit something, passing along information about the commit.

After setting up a Web Hook URL, all you need to do is click Next step button and activate web hook integration for the repository you have chosen.

Please Note: Only the account owner and admins are allowed to activate integrations. 


How to use it

Information about the commits is sent with JSON formatted data. On your side, you have a variety of options for parsing the post data. Check JSON homepage for a library in your favorite language.

http authentication on the web hooks

You can use http authentification on the web hooks, by providing the username/pass in the web hook url, like this:


What is included in the JSON data for SVN repositories?

The JSON formatted data sends the following data on each commit for SVN repositories:

  • Message: The comment from the commit.
  • Changed Files: The affected files.
  • Time: The time and date of the commit.
  • Author: The username of the person who made the commit.
  • Author's Full Name: The full name of the author.
  • Author's Email: Email address of the author.
  • Changeset URL: The URL to exact revision in Beanstalk's web application (not the SVN URL).
  • Revision: The revision number for this changeset.
  • Changed Directories: A list of directories that were updated.

JSON data example for SVN repository

Here is how JSON data which we send looks like:

  <code>{      "message": "Sample commit comment.",      "changed_files": [          ["README","edit"],          ["test/vimrc","edit"]      ],      "time": "2008/12/25 11:54:22 +0000",      "author": "daffy",      "author_full_name": "John Smith",      "author_email": "",      "changeset_url": "",      "revision": 2,      "changed_dirs": []  }

What is included in the JSON data for GIT repositories?

The JSON formatted data sends the following data on each commit for GIT repositories:

  • Before: hash of the last commit message before push
  • After: hash of the last commit message in the push (in case there were more than 1 commit, that would be the most recent commit before the push)
  • Push is To Large Flag: flag is set when there are more than 50 commit messages within push, in that case, commit container in JSON object would be emtpy
  • Ref: lists HEAD in the repository
  • Branch: branch on which user pushed the changes
  • URI: git reposority URL
  • Repository: contains name of the repository, and information about owner, whether repository is private, url to the account
  • Commits: contains information about commit hash (id), author of the commit, affected directories, files, url of the commit changeset, commit message, time when commit happened

JSON data example for GIT repository

Here is how JSON data which we send looks like:

  <code>{      "before": "7295fb96e74d1b54ba65cb003dce4da4193b5d29",      "after": "4ec8a1fcb42d278b60b33baa403a85c2e6706b5f",      "push_is_too_large": false,      "ref": "refs/heads/development",      "branch": "development",      "uri": "\/beanstalk.git",      "repository": {          "name": "beanstalk",          "owner": {            "email": "",            "name": "Dima Sabanin"          },          "private": true,          "url": "http:\/\/\/beanstalk"      },      "commits": [        {          "id": "4ec8a1fcb42d278b60b33baa403a85c2e6706b5f",          "author": {            "email": "",            "name": "Dima Sabanin"          },          "changed_dirs": [],          "changed_files": [            [              "db/schema.rb",              "edit"            ]          ],          "url": "",          "id": "4ec8a1fcb42d278b60b33baa403a85c2e6706b5f",          "message": "Updated schema",          "timestamp": "2010-04-14T17:54:16+08:00"        },        {          "id": "7295fb96e74d1b54ba65cb003dce4da4193b5d29",          "author": {            "email": "",            "name": "Dima Sabanin"          },          "changed_dirs": [],          "changed_files": [            [              "lib/hooks/git/git_adapter.rb",              "edit"            ]          ],          "url": "",          "id": "7295fb96e74d1b54ba65cb003dce4da4193b5d29",          "message": "Fixing &#39;Broken pipe&#39; error",          "timestamp": "2010-04-15T17:54:16+08:00"        }      ]  }

Still need help? Contact Us Contact Us