2015-04-20 17:26:44 +00:00
|
|
|
# webhookd
|
2014-09-19 18:46:04 +00:00
|
|
|
|
2015-12-11 13:58:57 +00:00
|
|
|
[![Image size](https://img.shields.io/imagelayers/image-size/ncarlier/webhookd/latest.svg)](https://hub.docker.com/r/ncarlier/webhookd/)
|
2015-12-11 14:00:41 +00:00
|
|
|
[![Docker pulls](https://img.shields.io/docker/pulls/ncarlier/webhookd.svg)](https://hub.docker.com/r/ncarlier/webhookd/)
|
2015-12-11 13:58:57 +00:00
|
|
|
|
2014-09-21 20:00:55 +00:00
|
|
|
A very simple webhook server to launch shell scripts.
|
|
|
|
|
2014-11-02 19:44:20 +00:00
|
|
|
It can be used as a cheap alternative of Docker hub in order to build private Docker images.
|
|
|
|
|
2015-04-20 17:26:44 +00:00
|
|
|
## Installation
|
2014-09-21 20:00:55 +00:00
|
|
|
|
2015-04-20 17:26:44 +00:00
|
|
|
### Binaries
|
2015-03-24 20:41:05 +00:00
|
|
|
|
2015-04-20 17:26:44 +00:00
|
|
|
Linux binaries for release [0.0.3](https://github.com/ncarlier/webhookd/releases)
|
2014-09-21 20:00:55 +00:00
|
|
|
|
2015-04-20 17:26:44 +00:00
|
|
|
* [amd64](https://github.com/ncarlier/webhookd/releases/download/v0.0.3/webhookd-linux-amd64-v0.0.3.tar.gz)
|
2014-09-21 20:00:55 +00:00
|
|
|
|
|
|
|
Download the version you need, untar, and install to your PATH.
|
|
|
|
|
2015-04-20 17:26:44 +00:00
|
|
|
```
|
|
|
|
$ wget https://github.com/ncarlier/webhookd/releases/download/v0.0.3/webhookd-linux-amd64-v0.0.3.tar.gz
|
|
|
|
$ tar xvzf webhookd-linux-amd64-v0.0.3.tar.gz
|
|
|
|
$ ./webhookd
|
|
|
|
```
|
2014-09-21 20:00:55 +00:00
|
|
|
|
2015-04-20 17:26:44 +00:00
|
|
|
### Docker
|
2015-03-24 20:41:05 +00:00
|
|
|
|
2015-04-20 17:26:44 +00:00
|
|
|
Start the container mounting your scripts directory:
|
2015-03-24 20:41:05 +00:00
|
|
|
|
2015-04-20 17:26:44 +00:00
|
|
|
```
|
|
|
|
$ docker run -d --name=webhookd \
|
|
|
|
--env-file etc/env.conf \
|
|
|
|
-v ${PWD}/scripts:/var/opt/webhookd/scripts \
|
|
|
|
-p 8080:8080 \
|
|
|
|
ncarlier/webhookd
|
|
|
|
```
|
2015-03-24 20:41:05 +00:00
|
|
|
|
2015-04-20 17:26:44 +00:00
|
|
|
The provided environment file (`etc/env.conf`) is used to configure the app.
|
|
|
|
Check [sample configuration](etc/env_sample.com) for details.
|
2015-03-24 20:41:05 +00:00
|
|
|
|
2015-04-20 17:26:44 +00:00
|
|
|
## Usage
|
2014-09-21 20:00:55 +00:00
|
|
|
|
|
|
|
Create your own scripts template in the **scripts** directory.
|
|
|
|
|
|
|
|
Respect the following structure:
|
|
|
|
|
2015-04-20 17:26:44 +00:00
|
|
|
```
|
|
|
|
/scripts
|
|
|
|
|--> /bitbucket
|
|
|
|
|--> /script_1.sh
|
|
|
|
|--> /script_2.sh
|
|
|
|
|--> /github
|
|
|
|
|--> /gitlab
|
|
|
|
|--> /docker
|
|
|
|
```
|
2014-09-21 20:00:55 +00:00
|
|
|
|
2015-03-24 20:41:05 +00:00
|
|
|
The hookname you will use will be related to the hook you want to use (github, bitbucket, ...) and the script name you want to call:
|
|
|
|
For instance if you are **gitlab** and want to call **build.sh** then you will need to use:
|
|
|
|
|
2015-04-20 17:26:44 +00:00
|
|
|
```
|
|
|
|
http://webhook_ip:port/gitlab/build
|
|
|
|
```
|
2015-03-24 20:41:05 +00:00
|
|
|
|
|
|
|
It is important to use the right hook in order for your script to received parameters extract from the hook payload.
|
|
|
|
|
2014-09-21 20:00:55 +00:00
|
|
|
|
|
|
|
For now, supported hooks are:
|
|
|
|
|
|
|
|
- GitHub
|
2015-03-20 10:58:57 +00:00
|
|
|
- Gitlab
|
2014-09-21 20:00:55 +00:00
|
|
|
- Bitbucket
|
|
|
|
- Docker Hub
|
|
|
|
|
|
|
|
|
|
|
|
Check the scripts directory for samples.
|
|
|
|
|
|
|
|
Once the action script created, you can trigger the webhook :
|
|
|
|
|
2015-04-20 17:26:44 +00:00
|
|
|
```
|
|
|
|
$ curl -H "Content-Type: application/json" \
|
|
|
|
--data @payload.json \
|
|
|
|
http://localhost:8080/<hookname>/<action>
|
|
|
|
```
|
2014-09-21 20:00:55 +00:00
|
|
|
|
|
|
|
The action script's output is collected and sent by email or by HTTP request.
|
|
|
|
|
|
|
|
The HTTP notification need some configuration:
|
|
|
|
|
|
|
|
- **APP_NOTIFIER**=http
|
|
|
|
- **APP_NOTIFIER_FROM**=webhookd <noreply@nunux.org>
|
|
|
|
- **APP_NOTIFIER_TO**=hostmaster@nunux.org
|
|
|
|
- **APP_HTTP_NOTIFIER_URL**=http://requestb.in/v9b229v9
|
|
|
|
|
|
|
|
> Note that the HTTP notification is compatible with [Mailgun](https://mailgun.com) API.
|
|
|
|
|
|
|
|
As the smtp notification:
|
|
|
|
|
|
|
|
- **APP_NOTIFIER**=smtp
|
|
|
|
- **APP_SMTP_NOTIFIER_HOST**=localhost:25
|
|
|
|
|
2014-09-19 18:46:04 +00:00
|
|
|
|