- Implemented with Python 3.
- Supports Github, Gitee, Gitlab, and custom repositories.
- Support custom working directory and command for different repositories.
- Support to install as the Systemd service.
- Clone or download this repository to any directory.
- Run
./install.sh
to install.
git clone https://github.com/troytse/git-webhooks-server.git
cd git-webhooks-server
./install.sh
cd git-webhooks-server
./install.sh --uninstal
- Add the following settings to your configuration file:
# match the full name of your repository
[your_name/repository]
# working directory
cwd=/path/to/your/repository
# the command executes on received the notification.
cmd=git fetch --all & git reset --hard origin/master & git pull
- Restart the service
systemctl restart git-webhooks-server
- Add webhook in the repository settings.
- for custom webhooks sources, you need to change the configuration file like follows:
[custom]
# used to identify the source
header_name=X-Custom-Header
header_value=Custom-Git-Hookshot
# used to match the secret
header_token=X-Custom-Token
# the path of the repository name in the json request data.
identifier_path=project.path_with_namespace
# only supports text token verification
verify=True
secret=123456
- Handler accepts POST data types with
application/json
orapplication/x-www-form-urlencoded
(you can refer to the guide about request in Github / Gitee / Gitlab), data is like this:
{
"project": {
"path_with_namespace": "your_name/repository"
}
}
- Default configuration file:
/usr/local/etc/git-webhooks-server.ini
. - You can modify it after the installation.
- A typical configuration file is as follows:
[server]
address=0.0.0.0
port=6789
log_file=/var/log/git-webhooks-server.log
[ssl]
enable=False
key_file=/path/to/key.pem
cert_file=/path/to/cert.pem
[github]
verify=True
secret=123456
[gitee]
verify=True
secret=123456
[gitlab]
verify=True
secret=123456
[custom]
header_name=X-Custom-Header
header_value=Custom-Git-Hookshot
header_token=X-Custom-Token
identifier_path=project.path_with_namespace
verify=True
secret=123456
[your_name/repository]
cwd=/path/to/your/repository
cmd=git fetch --all & git reset --hard origin/master & git pull
[your_name/sample]
cwd=/path/to/sample
cmd=git fetch --all & git reset --hard origin/master & git pull