Documentation for FishEye 3.0.x. Documentation for other versions is available too.

Web Hooks allow you to post changeset information to a specific URL. For each commit indexed by FishEye, the changeset data will be sent in JSON format to all configured URLs using a POST request.

You can use this feature to build integration with applications such as issue trackers, continuous integration solutions or notification systems.

Be aware that Web Hooks can expose private commit information. For example, using a public service could expose your code. Any user with administrative privileges in FishEye can create a Web Hook for any repository.

Adding Web Hooks

Web Hooks can be added or edited in from the configuration page accessible from the Administration interface.

Click on the Add button to create a new Web Hook. Choose a repository and enter your URL. Click Test and Save to verify and store your configuration. Web Hooks also support basic authentication, which can be configured in the Advanced Options.

Disabling Web Hooks

To disable Web Hooks, go to the Administration interface > Plugins

Show System Plugins and navigate to the FishEye/Crucible Web Hooks Plugin and click on the Disable button.

 

Demonstration of Web Hooks

PostBin is a service for debugging web hooks.

 

This is a public service and we do not recommend testing private repositories with public services as your code can be exposed.

Start by going to http://www.postbin.org and clicking on the Make a PostBin button.

Grab your PostBin URL and create a Web Hook with it using a test repository.

When you click on the Test button a dummy changeset will be sent to the PostBin URL. Refresh your PostBin page and you should see the data sent by FishEye.

This is a demonstration of the data sent by FishEye with a configured WebHook. The next step would be to write a service which captures this data and processes it.

Web Hook Data

Web Hooks will send changeset data in the following JSON representation:

{
    "repository": { 
        "name" : <repository name> 
    },
    "changeset" : {
        "csid" : <changeset id>,
        "displayId" : <changeset id>,
        "author" : <committer>,
        "comment" : <commit message>,
        "date" : <commit date>,
        "branches" : [ 
            <list of commit branches>
        ],
        "tags" : [ 
            <list of commit tags>
        ],
        "parents" : [
            <list of parents>
        ] 
    }
}

 

Sample Web Hook Scripts

The following script examples show you how to set up Web Hooks in various languages.

Python

This example requires the simplejson library installed.

import simplejson as json
import pprint
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer


class postRequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
                content_length = self.headers.getheader('content-length')
                if content_length:
                         content_length = int(content_length)
                if self.path.endswith('webhook'):
                        self.send_response(200)
                        self.end_headers()
                        body = self.rfile.read(content_length)
                        post_data = json.loads(body)
                        print 'Commit added with comment: %s' % post_data["changeset"]["comment"]

                else:
                        self.send_error(404, 'File Not Found %s' % self.path)
                
                return
                
                
def run():
        server = HTTPServer(('', 8081), postRequestHandler)
        print 'Server started'
        server.serve_forever()
                
if __name__ == '__main__':
        run()

Ruby and Sinatra

The example below would display the changeset information in the logs of the Sinatra server.

require 'rubygems'
require 'sinatra'
require 'json'

post '/' do
 changeset = JSON.parse(request.body.read)
 puts changeset.inspect 
end
  • No labels

2 Comments

  1. What will Fisheye do when the call to the remote system for the Web Hook fails?  Will the call be retried?  If the process doesn't succeed, is there a log file where the failure is written to?

    1. The call will not be retried. A message will be logged in the fisheye log, with the prefix "An error occured while executing Web Hook " and some identifying information about the hook that failed, and the response status code that was encountered. The message will be logged at ERROR level.