adnanh webhook 框架使用
adnanh webhook 支持以下功能:
- 接收请求
- 解析header 以及负载以及查询变量
- 规则检查
- 执行命令
简单测试
使用docker-compose
- docker-compose 文件
version: "3"
services:
webhook:
image: almir/webhook
command: ["-verbose", "-hooks=/etc/webhook/hooks.json","-hotreload"]
volumes:
- "./hooks.json:/etc/webhook/hooks.json"
ports:
- "9000:9000"
- hooks.json
匹配查询参数包含token=42 的才调用命令执行
[
{
"id": "simple-one",
"execute-command": "echo",
"response-message": "Executing simple webhook...",
"trigger-rule":
{
"match":
{
"type": "value",
"value": "42",
"parameter":
{
"source": "url",
"name": "token"
}
}
}
}
]
启动
- docker 启动
docker-compose up -d
- 测试
http://localhost:9000/hooks/simple-one?token=42
说明
webhook 使用起来还是比较简单的,同时也比较灵活,官方也提供了gitlab gogs jira 等的简单demo,还是不错的
参考资料
https://github.com/adnanh/webhook
https://hub.docker.com/r/almir/webhook/
https://github.com/rongfengliang/adnanh-webhook-docker-compose