mirror of
https://github.com/alvierahman90/gohookr.git
synced 2025-02-26 09:46:31 +00:00
Only execute if all tests are successful
This commit is contained in:
parent
c0f0cc6c60
commit
c99a5943aa
12
main.go
12
main.go
@ -71,6 +71,16 @@ func webhook(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run tests, immediately stop if one fails
|
||||||
|
for _, test := range service.Tests {
|
||||||
|
if _, err := exec.Command(test[0], test[1:]...).Output(); err != nil {
|
||||||
|
writeResponse(w, 409,
|
||||||
|
fmt.Sprintf("409 Conflict: Test failed: %v", err.Error()),
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if stdout, err := exec.Command(service.Script, payload).Output(); err != nil {
|
if stdout, err := exec.Command(service.Script, payload).Output(); err != nil {
|
||||||
writeResponse(w, 500, err.Error())
|
writeResponse(w, 500, err.Error())
|
||||||
return
|
return
|
||||||
@ -96,7 +106,7 @@ type Service struct {
|
|||||||
Script string
|
Script string
|
||||||
Secret string
|
Secret string
|
||||||
SignatureHeader string
|
SignatureHeader string
|
||||||
Tests []string
|
Tests [][]string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user