From e3e5d1e5f8e0178ca075ec0c744e358087ebed50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cynthia=20Revstr=C3=B6m?= Date: Thu, 23 Apr 2020 13:04:21 +0200 Subject: add workdir setting --- main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.go b/main.go index 2a20dab..e88d655 100644 --- a/main.go +++ b/main.go @@ -19,6 +19,7 @@ type cynciWebhookPayload struct { } type configJSON struct { + WorkDir string `json:"workdir"` Handlers map[string]string `json:"handlers"` WebhookTokens map[string]string `json:"webhook_tokens"` // map[token_name]token_value } @@ -57,6 +58,8 @@ func executeHandler(repoName string) error { return errors.New("no handler found") } + handler = filepath.Join(*dataPath, handler) + args := []string{handler} dt := time.Now().UTC().Format("2006-01-02_15-04-05.999") @@ -73,6 +76,11 @@ func executeHandler(repoName string) error { cmd.Stdout = logFile cmd.Stderr = logFile cmd.Dir = *dataPath + + if config.WorkDir != "" { + cmd.Dir = config.WorkDir + } + err = cmd.Run() if err != nil { return fmt.Errorf("failed to execute handler: %v", err) -- cgit v1.2.3