mirror of
https://github.com/drone/drone-cli.git
synced 2026-01-17 00:21:32 +01:00
Merge pull request #22 from thomasf/custom-payload
Add --payload argument
This commit is contained in:
commit
14ca393d57
@ -93,7 +93,11 @@ var ExecCmd = cli.Command{
|
||||
Usage: "hook event type",
|
||||
Value: "push",
|
||||
},
|
||||
cli.BoolTFlag{
|
||||
cli.StringFlag{
|
||||
Name: "payload",
|
||||
Usage: "merge the argument's json value with the normal payload",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
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))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user