Comments (10)
Great, thank you!
from webhook.
Hey there, what version of webhook are you using and what is your hooks.json definition for the given hook?
Here is a sample hooks.json definition:
[
{
"pass-arguments-to-command": [
{
"source": "entire-headers"
}
],
"execute-command": "/home/adnan/test.sh",
"id": "test"
}
]
test.sh script:
#!/bin/sh
echo $1 > /home/adnan/test.log
Trigger with curl:
curl localhost:9000/hooks/test
Webhook log after triggering the hook:
[webhook] 2016/10/31 13:31:51 version 2.5.0 starting
[webhook] 2016/10/31 13:31:51 setting up os signal watcher
[webhook] 2016/10/31 13:31:51 attempting to load hooks from hooks.json
[webhook] 2016/10/31 13:31:51 found 1 hook(s) in file
[webhook] 2016/10/31 13:31:51 loaded: test
[webhook] 2016/10/31 13:31:51 serving hooks on http://0.0.0.0:9000/hooks/{id}
[webhook] 2016/10/31 13:31:51 os signal watcher ready
[webhook] 2016/10/31 13:32:24 Started GET /hooks/test
[webhook] 2016/10/31 13:32:24 test got matched
[webhook] 2016/10/31 13:32:24 test hook triggered successfully
[webhook] 2016/10/31 13:32:24 Completed 200 OK in 44.258ยตs
[webhook] 2016/10/31 13:32:24 executing /home/adnan/test.sh (/home/adnan/test.sh) with arguments ["/home/adnan/test.sh" "{\"Accept\":\"*/*\",\"User-Agent\":\"curl/7.35.0\"}"] and environment [] using as cwd
[webhook] 2016/10/31 13:32:24 command output:
[webhook] 2016/10/31 13:32:24 finished handling test
Contents of test.log:
{"Accept":"*/*","User-Agent":"curl/7.35.0"}
from webhook.
Looking at your script in the commit that referenced this issue, $7 will be JSON string that contains all headers that have been passed to the webhook, it will never be equal to "ping". If you wanted the value from the header that contains ping ("X-Github-Event"?), you should reference it using the syntax you wrote:
{
"source": "header",
"name": "X-GitHub-Event"
}
from webhook.
I tried
{
"source": "header",
"name": "X-GitHub-Event"
}
first, and got an empty string. I then tried
{
"source": "entire-headers"
}
just to see if that would work. It also gives me an empty string.
from webhook.
Weird. Could you create the setup I used in the comment above and copy the webhook output?
from webhook.
Also, what version of webhook are you using?
from webhook.
And which OS is webhook running on?
from webhook.
[webhook] 2016/10/31 13:13:56 Started POST /hooks/email-pushbot
[webhook] 2016/10/31 13:13:56 email-pushbot got matched
[webhook] 2016/10/31 13:13:56 email-pushbot hook triggered successfully
[webhook] 2016/10/31 13:13:56 error extracting command arguments: couldn't retrieve argument for {Source:header Name:X-GitHub-Event EnvName:}
[webhook] 2016/10/31 13:13:56 executing /usr/bin/mailer (/usr/bin/mailer) with arguments ["/usr/bin/mailer" "/srv/git/pushbot" "refs/heads/master" "6db40f5186486801785a24241ffaf1a6ba0d2e1a" "328d298f0a8a44e8653430857eebf5d139c756b7" "jonhoo" "[email protected]" ""] and environment [] using /home/default as cwd
[webhook] 2016/10/31 13:13:56 command output: handling to /srv/git/pushbot
/srv/git/pushbot refs/heads/master 6db40f5186486801785a24241ffaf1a6ba0d2e1a 328d298f0a8a44e8653430857eebf5d139c756b7 jonhoo [email protected]
pushed by: jonhoo <[email protected]>
aliased to Jon Gjengset <[email protected]>
syncing with upstream
Fetching origin
invoking post-receive-email with
6db40f5186486801785a24241ffaf1a6ba0d2e1a
328d298f0a8a44e8653430857eebf5d139c756b7
refs/heads/master
all done
[webhook] 2016/10/31 13:13:56 finished handling email-pushbot
[webhook] 2016/10/31 13:13:56 Completed 200 OK in 392.731546ms
$ git -C go/src/github.com/adnanh/webhook/ rev-parse HEAD
7d525cf317b7f0e45b9e7e1a1658b4633154ec01
Running Arch Linux.
from webhook.
Aha! Finally got it!
From RFC 2616 - "Hypertext Transfer Protocol -- HTTP/1.1", Section 4.2, "Message Headers":
Each header field consists of a name followed by a colon (":") and the field value. Field names are case-insensitive.
What Golang http package does is normalizes the keys in the request headers map using the "Title case", making webhook unable to extract X-Git_Hub_-Event because in the hash map it's under X-Git_hub_-Event.
As a temporary workaround you can use the X-Github-Event as a header name.
Good catch, thanks!
2.6.0 coming right up!
from webhook.
Fixed in 2.6.0.
Thanks a lot for your feedback!
from webhook.
Related Issues (20)
- Broadcasting Slack Slash Command's Response HOT 1
- Header evaluation is broken HOT 4
- Step-by-step tutorial for a 'Hello world'
- Vulnerabilities of dependency "gopkg.in/yaml.v2"
- webhook hook not running bash script HOT 6
- Bitbucket now supports webhook secrets ๐ฅณ HOT 1
- I found that I can't use dot-notation to contain all sub-objects in my json
- I need to parse url for addr:port HOT 1
- Update `go` installation
- Ubuntu Webhooks is not reading the correct RVM ruby installed HOT 2
- Custom logging
- Webhook id is not being served in URL HOT 2
- how to set shell $PATH HOT 4
- Weird Cert issue when calling webhook from shell HOT 1
- pass-file-to-command as optional HOT 1
- Add a (unique) folder with images for dynamic responses HOT 7
- Question - How long does the webhook service run
- Add hook property to control command output logging
- New WebHook, Docker, Env Support, Clean codebase ๐
- amd64 does not works pre compiled? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webhook.