From f1b90d677d14b440092a9d494ef57f584475ca5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Taka=CC=81cs?= Date: Fri, 9 Jan 2015 14:55:09 +0100 Subject: [PATCH] support commands with arguments --- gitlab-webhook.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gitlab-webhook.go b/gitlab-webhook.go index a7e934e..5493fbc 100644 --- a/gitlab-webhook.go +++ b/gitlab-webhook.go @@ -12,6 +12,7 @@ import( //"fmt" "os/signal" "syscall" + "strings" ) //GitlabRepository represents repository information from the webhook @@ -156,10 +157,14 @@ func hookHandler(w http.ResponseWriter, r *http.Request) { //find matching config for repository name for _, repo := range config.Repositories { if(repo.Name != hook.Repository.Name) { continue } - + //execute commands for repository for _, cmd := range repo.Commands { - var command = exec.Command(cmd) + parts := strings.Fields(cmd) + head := parts[0] + parts = parts[1:len(parts)] + var command = exec.Command(head, parts...) + err = command.Run() if(err != nil) { log.Println(err)