Add CaptureCommandOutputOnError

to include stdout & stderror in failed executions,
with docs.
This commit is contained in:
Greg Dubicki 2017-08-27 10:23:59 +02:00
parent 44d19e34a0
commit a40fba5e29
3 changed files with 8 additions and 2 deletions

View file

@ -282,9 +282,13 @@ func hookHandler(w http.ResponseWriter, r *http.Request) {
response, err := handleHook(matchedHook, rid, &headers, &query, &payload, &body)
if err != nil {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, "Error occurred while executing the hook's command. Please check your logs for more details.")
if matchedHook.CaptureCommandOutputOnError {
fmt.Fprintf(w, response)
} else {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
fmt.Fprintf(w, "Error occurred while executing the hook's command. Please check your logs for more details.")
}
} else {
fmt.Fprintf(w, response)
}