summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2014-05-14 13:48:51 +0200
committerJacob Vosmaer <contact@jacobvosmaer.nl>2014-05-14 13:49:16 +0200
commitad7de951214fcfa9a0677b2b8bd669b5bd07d83e (patch)
tree668a259b13ea623b7d5f614fa5d504d399641f44
parentf18f8e675594ba86a59176933f2521a9c6ec9f2f (diff)
downloadgitlab-ce-ad7de951214fcfa9a0677b2b8bd669b5bd07d83e.tar.gz
Add an example webhook receiver
-rw-r--r--doc/web_hooks/web_hooks.md31
1 files changed, 31 insertions, 0 deletions
diff --git a/doc/web_hooks/web_hooks.md b/doc/web_hooks/web_hooks.md
index 5ad0c8a138f..a223d83da3f 100644
--- a/doc/web_hooks/web_hooks.md
+++ b/doc/web_hooks/web_hooks.md
@@ -112,3 +112,34 @@ Triggered when a new merge request is created or an existing merge request was u
}
}
```
+
+#### Example webhook receiver
+
+If you want to see GitLab's webhooks in action for testing purposes you can use
+a simple echo script running in a console session.
+
+Save the following file as `print_http_body.rb`.
+
+```ruby
+require 'webrick'
+
+server = WEBrick::HTTPServer.new(Port: ARGV.first)
+server.mount_proc '/' do |req, res|
+ puts req.body
+end
+
+trap 'INT' do server.shutdown end
+server.start
+```
+
+Pick an unused port (e.g. 8000) and start the script: `ruby print_http_body.rb
+8000`. Then add your server as a webhook receiver in GitLab as
+`http://my.host:8000/`.
+
+When you press 'Test Hook' in GitLab, you should see something like this in the console.
+
+```
+{"before":"077a85dd266e6f3573ef7e9ef8ce3343ad659c4e","after":"95cd4a99e93bc4bbabacfa2cd10e6725b1403c60",<SNIP>}
+localhost - - [14/May/2014:07:45:26 EDT] "POST / HTTP/1.1" 200 0
+- -> /
+```