From c009264ea9e88873fa6fa6660f1725048e210028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Fr=C3=B6ssman?= Date: Mon, 4 Apr 2016 12:52:16 +0200 Subject: [PATCH 1/2] Add build --payload argument Also added printing of payload when -debug argument is specified. --- drone/exec.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drone/exec.go b/drone/exec.go index d44f9c3..2d87993 100644 --- a/drone/exec.go +++ b/drone/exec.go @@ -93,6 +93,10 @@ var ExecCmd = cli.Command{ Usage: "hook event type", Value: "push", }, + cli.StringFlag{ + Name: "payload", + Usage: "merge the argument's json value with the normal payload", + }, cli.BoolTFlag{ Name: "debug", Usage: "execute the build in debug mode", @@ -241,6 +245,19 @@ func execCmd(c *cli.Context) error { if len(proj) != 0 { payload.Repo.Link = fmt.Sprintf("https://%s", proj) } + if c.IsSet("payload") { + err := json.Unmarshal([]byte(c.String("payload")), &payload) + if err != nil { + color.Red("Error reading --payload argument, it must be valid json: %v", err) + os.Exit(1) + } + } + if c.Bool("debug") { + out, _ := json.MarshalIndent(payload, " ", " ") + color.Magenta("[DRONE] job #%d payload:", i+1) + fmt.Println(string(out)) + } + out, _ := json.Marshal(payload) exit, err := run(cli, execArgs, string(out)) From 3c30a960e1b03122828201af60940d3622527b3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Fr=C3=B6ssman?= Date: Sun, 10 Apr 2016 14:48:35 +0200 Subject: [PATCH 2/2] Change --debug to default to false All other bool flags behave like this and (to me) the command help section indicates that this is the expected behaviour. --- drone/exec.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drone/exec.go b/drone/exec.go index 2d87993..c2a6953 100644 --- a/drone/exec.go +++ b/drone/exec.go @@ -97,7 +97,7 @@ var ExecCmd = cli.Command{ Name: "payload", Usage: "merge the argument's json value with the normal payload", }, - cli.BoolTFlag{ + cli.BoolFlag{ Name: "debug", Usage: "execute the build in debug mode", },