webhookd 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +77 -4
- data/etc/example.yml +1 -0
- data/lib/webhookd/app.rb +3 -1
- data/lib/webhookd/command_runner.rb +3 -3
- data/lib/webhookd/payloadtype/bitbucket.rb +1 -1
- data/lib/webhookd/payloadtype/debug.rb +21 -0
- data/lib/webhookd/payloadtype/gitlab.rb +1 -1
- data/lib/webhookd/version.rb +1 -1
- data/scripts/webhookd.init +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be015c3eefbb47481f8dfc39b40dfa7d9f1a88f1
|
4
|
+
data.tar.gz: 68d5c088ba11143893aedccf9f8b735704658d69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5afc2914a4114983cb50b9c7a6909e671719143cd8c9a1ed67f49a2bd24bf633850c15f5eaa3ffa86d5372b906eaac8bab6cc8ea8e53493ad5e4a63ee6bcf38
|
7
|
+
data.tar.gz: 9cc1d79f8301ff6cdb0d8d52143093486a444c35ffd89a9c8e324c7ba6d3674dedbaa068eac4ab0d76d63955479c6f2dc934d0e2ac6bcadf7dcf8887eebe87ee
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# WebhookD
|
2
2
|
|
3
3
|
**Flexible, configurable universal webhook receiver**
|
4
4
|
|
@@ -129,6 +129,16 @@ vcs:
|
|
129
129
|
command: 'echo this is the repo <%= repo_name.upcase %>'
|
130
130
|
```
|
131
131
|
|
132
|
+
### Webhook usage
|
133
|
+
|
134
|
+
The use a webhook, add the URL to your project.
|
135
|
+
|
136
|
+
**Available webhook payload types**
|
137
|
+
|
138
|
+
* *Bitbucket*: http(s)://USERNAME:PASSWORD@YOURIP:YOURPORT/payload/bitbucket
|
139
|
+
* *Gitlab*: http(s)://USERNAME:PASSWORD@YOURIP:YOURPORT/payload/gitlab
|
140
|
+
* *Debug*: http(s)://USERNAME:PASSWORD@YOURIP:YOURPORT/payload/debug
|
141
|
+
|
132
142
|
### Testing
|
133
143
|
|
134
144
|
There are some tests in place using `minitest`. Run `rake test` to run all available test.
|
@@ -152,6 +162,7 @@ For an example have a look at `lib/webhookd/payloadtype/bitbucket.rb`.
|
|
152
162
|
Adding a new type would involve the following steps:
|
153
163
|
1. Write a payload parser in `lib/webhookd/payloadtype/`
|
154
164
|
1. Add business logic for the payload type in `lib/webhookd/app.rb` under `case parsed_data[:type]`
|
165
|
+
1. Update README.md
|
155
166
|
|
156
167
|
### Payload parser
|
157
168
|
|
@@ -170,7 +181,69 @@ data[:branch_name]
|
|
170
181
|
data[:author_name]
|
171
182
|
```
|
172
183
|
|
173
|
-
|
184
|
+
**debug**
|
185
|
+
|
186
|
+
The `debug` payload type has the following hash signature:
|
187
|
+
|
188
|
+
```ruby
|
189
|
+
data[:type]
|
190
|
+
```
|
191
|
+
|
192
|
+
It can be used to develop a new payload type or payload parser.
|
193
|
+
When using this payload type, it just outputs the request body
|
194
|
+
in the logfile under the loglevel `debug`.
|
195
|
+
|
196
|
+
## Packaging
|
197
|
+
|
198
|
+
### Debian
|
199
|
+
|
200
|
+
Some very basic Debian packaging effort can be found under [tobru/webhookd-debian-packaging](https://github.com/tobru/webhookd-debian-packaging).
|
201
|
+
This is how the initial package creation was done:
|
202
|
+
|
203
|
+
```
|
204
|
+
export DEBFULLNAME="My Name"
|
205
|
+
export DEBEMAIL="email@address.com"
|
206
|
+
gem fetch webhookd
|
207
|
+
gem2deb -p webhookd webhookd*.gem
|
208
|
+
cd webhookd-<VERSION>
|
209
|
+
git init
|
210
|
+
git-import-orig ../webhookd_*.orig.tar.gz --pristine-tar
|
211
|
+
cd ..
|
212
|
+
mv webhookd-<VERSION> webhookd
|
213
|
+
cd webhookd
|
214
|
+
|
215
|
+
# EDIT .gitignore
|
216
|
+
vi .gitignore
|
217
|
+
|
218
|
+
# add following lines
|
219
|
+
/debian/webhookd.postinst.debhelper
|
220
|
+
/debian/webhookd.postrm.debhelper
|
221
|
+
/debian/webhookd.prerm.debhelper
|
222
|
+
/debian/webhookd.substvars
|
223
|
+
/debian/webhookd
|
224
|
+
/debian/files
|
225
|
+
/.pc
|
226
|
+
Gemfile.lock
|
227
|
+
|
228
|
+
:wq
|
229
|
+
# END EDIT
|
230
|
+
|
231
|
+
git add .
|
232
|
+
git commit -a
|
233
|
+
git-buildpackage -us -uc
|
234
|
+
```
|
235
|
+
|
236
|
+
After changes to the packaging process (`/debian` folder):
|
237
|
+
```
|
238
|
+
dch -v <upstreamver>-<incrementpkgrel>
|
239
|
+
git commit -a
|
240
|
+
rm Gemfile.lock
|
241
|
+
git-buildpackage -us -uc
|
242
|
+
```
|
243
|
+
|
244
|
+
If there is a new upstream version:
|
245
|
+
```
|
246
|
+
gem fetch webhookd && gem2deb webhookd*.gem ; git-import-orig
|
247
|
+
dch -v <upstreamver>-<incrementpkgrel>
|
248
|
+
```
|
174
249
|
|
175
|
-
* Regex match for repository and branch names
|
176
|
-
* Notification mechanism (jabber, irc)
|
data/etc/example.yml
CHANGED
data/lib/webhookd/app.rb
CHANGED
@@ -129,6 +129,8 @@ module Webhookd
|
|
129
129
|
command_runner.run
|
130
130
|
end
|
131
131
|
# we don't know the type of this known payload
|
132
|
+
when 'debug'
|
133
|
+
logger.info "payload type was debug, see debug loglevel"
|
132
134
|
else
|
133
135
|
error_msg = "webhook payload type #{parsed_data[:type]} unknown"
|
134
136
|
logger.fatal error_msg
|
@@ -137,7 +139,7 @@ module Webhookd
|
|
137
139
|
# this type of payload is not configured
|
138
140
|
else
|
139
141
|
error_msg = "webhook payload of type #{parsed_data[:type]} not configured"
|
140
|
-
logger.
|
142
|
+
logger.error error_msg
|
141
143
|
halt 500, "#{error_msg}\n"
|
142
144
|
end
|
143
145
|
|
@@ -15,10 +15,10 @@ module Webhookd
|
|
15
15
|
logger.info "Running command: #{@command}"
|
16
16
|
Open3::popen2e(@command) { |stdin, stdout_err, wait_thr|
|
17
17
|
while line = stdout_err.gets
|
18
|
-
logger.
|
18
|
+
logger.info("STDOUTERR: #{line.strip}")
|
19
19
|
end
|
20
20
|
if wait_thr.value.success?
|
21
|
-
logger.info "command
|
21
|
+
logger.info "command successfully finished"
|
22
22
|
return true
|
23
23
|
else
|
24
24
|
logger.error "command failed"
|
@@ -26,7 +26,7 @@ module Webhookd
|
|
26
26
|
end
|
27
27
|
}
|
28
28
|
rescue Exception => e
|
29
|
-
logger.fatal "
|
29
|
+
logger.fatal "command running completely failed: #{e.message}"
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'webhookd/logging'
|
2
|
+
module Webhookd
|
3
|
+
class ParsePayload
|
4
|
+
|
5
|
+
include Logging
|
6
|
+
|
7
|
+
def initialize(payload)
|
8
|
+
@payload = payload
|
9
|
+
end
|
10
|
+
|
11
|
+
def parse
|
12
|
+
logger.debug 'parsing payload type debug'
|
13
|
+
logger.debug "raw received data: #{@payload}"
|
14
|
+
|
15
|
+
data = Hash.new
|
16
|
+
data[:type] = 'debug'
|
17
|
+
|
18
|
+
data
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -22,7 +22,7 @@ module Webhookd
|
|
22
22
|
data[:branch_name] = json_parsed['ref'].split("/")[2]
|
23
23
|
data[:author_name] = json_parsed['user_name']
|
24
24
|
|
25
|
-
logger.
|
25
|
+
logger.info "parsed from the gitlab data: #{data}"
|
26
26
|
|
27
27
|
# return the hash
|
28
28
|
data
|
data/lib/webhookd/version.rb
CHANGED
data/scripts/webhookd.init
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webhookd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Brunner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- lib/webhookd/configuration.rb
|
140
140
|
- lib/webhookd/logging.rb
|
141
141
|
- lib/webhookd/payloadtype/bitbucket.rb
|
142
|
+
- lib/webhookd/payloadtype/debug.rb
|
142
143
|
- lib/webhookd/payloadtype/gitlab.rb
|
143
144
|
- lib/webhookd/version.rb
|
144
145
|
- scripts/test/curl-bitbucket-explicit-repo-and-branch.sh
|