webhook
webhook copied to clipboard
http-methods parameter is not working
I configured my webhook to only trigger for POSTs, webhook should not trigger for GETs because firing a webhook by definition is not idempotent.
However it still fires when receiving GET requests. This is my config:
jasper@jasper-wtf:~$ cat /etc/webhook.conf
[
{
"id": "redeploy-webhook",
"execute-command": "/home/jasper/deploy.sh",
"command-working-directory": "/home/jasper",
"response-message": "Deploying...",
"http-methods": ["POST"],
"trigger-rule": {
"match": {
"type": "value",
"value": "bla",
"parameter": {
"source": "header",
"name": "X-Bla"
}
}
}
}
]
This is the log of an incoming GET:
jasper@jasper-wtf:~$ webhook -hooks /etc/webhook.conf --verbose
[webhook] 2021/02/09 14:52:20 version 2.6.9 starting
[webhook] 2021/02/09 14:52:20 setting up os signal watcher
[webhook] 2021/02/09 14:52:20 attempting to load hooks from /etc/webhook.conf
[webhook] 2021/02/09 14:52:20 found 1 hook(s) in file
[webhook] 2021/02/09 14:52:20 loaded: redeploy-webhook
[webhook] 2021/02/09 14:52:20 serving hooks on http://0.0.0.0:9000/hooks/{id}
[webhook] 2021/02/09 14:52:20 os signal watcher ready
[webhook] 2021/02/09 14:52:22 Started GET /hooks/redeploy-webhook
[webhook] 2021/02/09 14:52:22 [d573db] incoming HTTP request from 81.173.75.97:51154
[webhook] 2021/02/09 14:52:22 [d573db] redeploy-webhook got matched
[webhook] 2021/02/09 14:52:22 [d573db] redeploy-webhook hook triggered successfully
[webhook] 2021/02/09 14:52:22 Completed 200 OK in 1.527574ms
[webhook] 2021/02/09 14:52:22 [d573db] executing /home/jasper/deploy.sh (/home/jasper/deploy.sh) with arguments ["/home/jasper/deploy.sh"] and environment [] using /home/jasper as cwd
[webhook] 2021/02/09 14:52:22 [d573db] command output:
[webhook] 2021/02/09 14:52:22 [d573db] finished handling redeploy-webhook
That feature was added in 2.7.0.
Is there any way I can use a newer version on 18.04 without using snap?
I tried installing it with snap but my user experience has been terrible:
- webhook is not installed in the /snap/bin so the command is by default not in my path
- it doesn't come with a systemd setup, have to create your own service
- running it with snap runs into some extremely weird permission issues, running it as root gives a permission denied for the webhook config file owned by the root user, when running it non privileged the triggered webhook suddenly has an entirely different path and can't find any command I reference in the webhook triggered script
Perhaps @adnanh has some insight. I deploy webhook with a private Ansible role and avoid rpm/deb/snap packages.
I also prefer to avoid package-managers. :(
Maybe a quick hack would be to download binary and overwrite the one that the package provided?