Commit graph

135 commits

Author SHA1 Message Date
Marco Descher
c9abc252e8 Delete hook files by default 2017-11-07 16:38:12 +01:00
Marco Descher
6145634670 Adapt to #173 2017-11-07 16:19:22 +01:00
Marco Descher
41b75acc70
Merge branch 'master' into master 2017-11-07 16:14:47 +01:00
Adnan Hajdarević
65bd1cdd10
Update webhook.go 2017-11-04 20:49:57 +01:00
Marco Descher
213e4529e8 #162 do use temporary files, provide env variable 2017-09-15 13:30:44 +02:00
Adnan Hajdarević
f0e26bc03c Merge pull request #164 from ivanpesin/static-parameter-warning
Static parameter warning
2017-09-14 19:44:16 +02:00
Ivan Pesin
da39872a77 Add request-id to verbose log messages 2017-09-12 23:12:12 -05:00
Ivan Pesin
142e912d6a Fix to support hot reload with vim editor changes 2017-09-12 00:10:16 -05:00
Marco Descher
78aa85e0c1 Revert to original hook import 2017-08-30 14:23:29 +02:00
Marco Descher
395fb41d23 Provide means to transfer files #162 add deleteOnExit 2017-08-29 14:42:14 +02:00
Ivan Pesin
1fc4445668 Produce warnings if unable to locate binary and if static parameters specified erroneously 2017-08-25 23:31:02 -04:00
Ivan Pesin
d52d7bde1c Fixed source code formatting with go fmt (spaces to tabs) 2017-08-25 23:30:08 -04:00
Marco Descher
34c4b1c166 Provide means to transfer files #162 2017-08-25 15:01:57 +02:00
Adnan Hajdarevic
cfd138c96d Fix #141 2017-08-09 09:52:59 +02:00
ilkelma
3a75bbf4db Change to CombinedOutput to consume Stderr as well 2017-06-13 16:23:59 -04:00
Adnan Hajdarevic
a38875213a fix tests, log ip of the incoming request, bump version 2017-05-27 17:14:38 +02:00
Adnan Hajdarevic
81b1bd7c7b bump up the version to 2.6.3 2017-04-07 10:59:40 +02:00
HandcraftedBits
173273b466 Add IP whitelist match rule. 2017-02-20 22:00:39 -05:00
Adnan Hajdarevic
c8a83349d2 remove hooks after the underlying file is removed 2017-02-11 22:58:49 +01:00
Adnan Hajdarevic
1da40d4634 Merge branch 'master' into development 2017-02-11 12:15:04 +01:00
Adnan Hajdarević
c51971fd37 Bump version 2017-02-10 19:19:53 +01:00
Mathias Merscher
058f820cbd rename trigger rule http response code config option
Signed-off-by: Mathias Merscher <Mathias.Merscher@dg-i.net>
2017-02-10 18:42:02 +01:00
Mathias Merscher
ddb1f2441a make http return code for mismatched rules configurable
Signed-off-by: Mathias Merscher <Mathias.Merscher@dg-i.net>
2017-02-10 12:32:11 +01:00
Adnan Hajdarevic
79453b7a22 Use hooks.json as default file if no hooks file have been specified 2016-12-05 21:28:38 +01:00
Adnan Hajdarevic
8207c6cf12 Started work on multi file hooks loading 2016-12-05 21:22:34 +01:00
Adnan Hajdarevic
ecbcf11153 fix #106 2016-11-01 20:09:41 +01:00
Adnan Hajdarevic
75cf8952be remove \n 2016-09-29 20:11:20 +02:00
Adnan Hajdarevic
c53596df59 override content type header when returning error message 2016-09-29 20:08:47 +02:00
Adnan Hajdarevic
cc0d9b2cba fix tests, return raw output, return 500 if the command did not execute properly - fixes #87
return raw stdout instead of json wrapped message - fixes #88
2016-09-29 19:57:06 +02:00
Adnan Hajdarevic
1943c5311f bump version to 2.5.0 2016-09-29 19:16:47 +02:00
Cameron Moore
b5ed4cbea7 Update negroni Logger usage
negroni made a breaking change to the Logger struct.

Fixes #91
2016-09-02 08:57:46 -05:00
Adnan Hajdarević
54a9dbe1d6 fixes #76, fixes #78, fixes #82, fixes #83 (#84) 2016-06-27 22:15:37 +02:00
Adnan Hajdarevic
3bcf6d5e2b bump version to 2.3.9 2016-06-18 15:33:37 +02:00
Adnan Hajdarević
4d20af8027 Update webhook.go 2016-03-24 16:43:42 +01:00
Adnan Hajdarevic
37698e63b6 add support for setting global response headers using -header flag
add support for setting response headers for a successfuly triggered hook
2016-02-27 22:13:09 +01:00
Adnan Hajdarevic
f59f0a5c84 - added omitempty to json fields 2015-12-27 20:05:52 +01:00
Cameron Moore
d2e315d9c6 Fix environment and argument passing
Two issues are addressed in this commit:

1. Instead of only sending the predefined environment arguments, this
commit appends the arguments to the existing OS environment.  Fixes #53.

2. If an argument is not found in the payload, allow the command to run
and pass in an empty string as a placeholder.  Fixes #54.

Additionally, I replaced `hook.ErrInvalidPayloadSignature` with a new
`SignatureError` type so that we can embed the signature in the error.
2015-11-18 12:00:47 -06:00
Adnan Hajdarevic
82bba7ba07 bump up the version 2015-11-13 09:24:17 +01:00
Cameron Moore
ea3dbf3438 Add environment arguments and improve testing
There's a lot in this commit.

 1. Add `pass-environment-to-command` option that works much like
 `pass-arguments-to-command`.  You can see an example usage in the
 "github" test case.

 2. Add a test program called "hookecho" that is used to test the
 webhook package instead of relying upon a system `echo` command.

 3. Move hooks_test.json to a template so that we can update the path to
 hookecho on the fly.

 4. Don't return an error at the end of hook.MatchRule.Evaluate().  All
 tests succeed for me now.
2015-11-02 15:11:23 -06:00
Adnan Hajdarević
6774079a57 Merge pull request #46 from moorereason/testing
Add testing framework for main webhook app
2015-10-31 09:29:34 +01:00
Adnan Hajdarević
334fbc814c Merge pull request #45 from moorereason/signals
Refactor signal handling and Windows support
2015-10-31 09:29:22 +01:00
Cameron Moore
802f3f572c Add testing framework for main webhook app
This commit adds a testing framework modeled after the godoc tests. It builds
webhook in a temporary directory, runs it with the supplied `hooks_test.json`
configuration, and then tests different payloads.  I use `/bin/echo` for the
test executable, so I've added build tags to exclude Windows.

Three minor (I hope) changes in functionality:

- I ended up moving everything from `init()` to `main()` because `init()` was
  firing while trying to build the tests, and it was dying since `hooks.json`
  didn't exist. I'm still not 100% sure `init()` was firing, but I didn't see
  any real need for anything to be in `init()` in the first place.

- make sure logger is using `os.Stderr`

- don't send `http.StatusBadRequest` when the Hook rules don't match.  "Bad
  Request" is used to identify malformed requests.  The request was properly
  formed and processed, so I think we should send back `http.StatusOK`.  For
  example, if I setup a webhook rule to only execute when commits are made to
  the `master` branch, we shouldn't send back `http.StatusBadRequest` when we
  ingest a payload for the `development` branch.

The test payloads are pretty verbose and could probably be shortened, but I kind
of like having an example payload for each service.  We can pare them down if we
want to do more focused, minimalist testing.
2015-10-30 21:32:48 -05:00
Cameron Moore
1c319a7a08 Refactor signal handling and Windows support
This commit drops webhook_windows.go in favor of simply pulling out the
signal handling code to separate files.
2015-10-29 11:17:15 -05:00
Cameron Moore
2947e5e0e8 Remove logging side-effects from hook package
The hook package should be self-contained and return errors instead of
relying on the log subsystem.  This commit removes the logging
side-effects from the hook package.  Custom errors are returned that
should be transparent to the caller -- they can just treat them as
simple errors if they don't care to check the type.
2015-10-29 11:00:30 -05:00
Adnan Hajdarevic
272546bb2b add nopanic flag 2015-10-04 17:06:17 +02:00
Adnan Hajdarevic
9977fa8c61 refactor 2015-06-06 14:28:00 +02:00
Adnan Hajdarevic
9c545a745f return command output, pass whole payload as json to the command 2015-06-06 14:19:52 +02:00
Adnan Hajdarevic
f1ebc440a4 match all hooks with the same id 2015-05-27 09:16:26 +02:00
Adnan Hajdarevic
4350685330 separated windows and other platforms to different files, removed signal watcher from windows build file so webhook can actually compile on windows, added string as a source, so you can pass static strings to your scripts without having to wrap them around with other scripts 2015-05-16 13:32:21 +02:00
Kevin Le Brun
6cd8258651 Fix for OS X USR1 signal
It seems that signals code for Linux and OS X (FreeBSD) are different. I
rely on `syscall.SIGUSR1` which should be cross-compatible.

Tested with `kill -usr1 <pid>` on OS X 10.10
2015-04-05 23:21:40 +02:00