From afc3030087260b51f901b9f674c0d6a9d7b01bb7 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Sun, 12 Oct 2014 14:07:28 -0700 Subject: [PATCH] ability to pass --deploy and --publish flags to `drone build` --- cli/build.go | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/cli/build.go b/cli/build.go index cceb954ce..134e91040 100644 --- a/cli/build.go +++ b/cli/build.go @@ -34,6 +34,16 @@ func NewBuildCommand() cli.Command { Value: "false", Usage: "runs drone build in a privileged container", }, + cli.StringFlag{ + Name: "deploy", + Value: "false", + Usage: "runs drone build with deployments enabled", + }, + cli.StringFlag{ + Name: "publish", + Value: "false", + Usage: "runs drone build with publishing enabled", + }, }, Action: func(c *cli.Context) { buildCommandFunc(c) @@ -45,6 +55,8 @@ func NewBuildCommand() cli.Command { func buildCommandFunc(c *cli.Context) { var privileged = c.Bool("p") var identity = c.String("i") + var deploy = c.Bool("deploy") + var publish = c.Bool("publish") var path string // the path is provided as an optional argument that @@ -71,11 +83,11 @@ func buildCommandFunc(c *cli.Context) { log.SetPriority(log.LOG_DEBUG) //LOG_NOTICE docker.Logging = false - var exit, _ = run(path, identity, privileged) + var exit, _ = run(path, identity, publish, deploy, privileged) os.Exit(exit) } -func run(path, identity string, privileged bool) (int, error) { +func run(path, identity string, publish, deploy, privileged bool) (int, error) { dockerClient := docker.New() // parse the private environment variables @@ -93,10 +105,12 @@ func run(path, identity string, privileged bool) (int, error) { s.Env = append(s.Env, key+"="+val) } - // remove deploy & publish sections - // for now, until I fix bug - s.Publish = nil - s.Deploy = nil + if deploy == false { + s.Publish = nil + } + if publish == false { + s.Deploy = nil + } // get the repository root directory dir := filepath.Dir(path) @@ -144,7 +158,6 @@ func run(path, identity string, privileged bool) (int, error) { builder.Repo = &code builder.Key = key builder.Stdout = os.Stdout - // TODO ADD THIS BACK builder.Timeout = 300 * time.Minute builder.Privileged = privileged