From f3c06a8fc3064e27111ad84cdd1d65e2f18cdbde Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Tue, 19 May 2015 21:22:31 -0700 Subject: [PATCH] global environment parameters --- cmd/drone-build/run.go | 18 +++++++----------- pkg/queue/worker.go | 1 + pkg/runner/builtin/runner.go | 1 + pkg/runner/builtin/worker.go | 1 + 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cmd/drone-build/run.go b/cmd/drone-build/run.go index 134f9b517..153060272 100644 --- a/cmd/drone-build/run.go +++ b/cmd/drone-build/run.go @@ -20,7 +20,9 @@ type Context struct { Keys *common.Keypair `json:"keys"` Netrc *common.Netrc `json:"netrc"` Yaml []byte `json:"yaml"` - Conf *common.Config `json:"-"` + Env []string `json:"env"` + + Conf *common.Config `json:"-"` infos []*dockerclient.ContainerInfo client dockerclient.Client } @@ -126,16 +128,6 @@ func execCompose(c *Context) (int, error) { return 0, nil } -func trace(s string) string { - cmd := fmt.Sprintf("$ %s\n", s) - encoded := base64.StdEncoding.EncodeToString([]byte(cmd)) - return fmt.Sprintf("echo %s | base64 --decode\n", encoded) -} - -func newline(s string) string { - return fmt.Sprintf("%s\n", s) -} - func runSteps(c *Context, steps map[string]*common.Step) (int, error) { for _, step := range steps { @@ -151,6 +143,10 @@ func runSteps(c *Context, steps map[string]*common.Step) (int, error) { conf := toContainerConfig(step) conf.Cmd = toCommand(c, step) + + // append global environment variables + conf.Env = append(conf.Env, c.Env) + info, err := run(c.client, conf, step.Pull) if err != nil { return 255, err diff --git a/pkg/queue/worker.go b/pkg/queue/worker.go index 997bb1b68..affbb4adc 100644 --- a/pkg/queue/worker.go +++ b/pkg/queue/worker.go @@ -15,6 +15,7 @@ type Work struct { Keys *common.Keypair `json:"keypair"` Netrc *common.Netrc `json:"netrc"` Yaml []byte `json:"yaml"` + Env []string `json:"env"` } // represents a worker that has connected diff --git a/pkg/runner/builtin/runner.go b/pkg/runner/builtin/runner.go index 249ce6cb2..2493808ac 100644 --- a/pkg/runner/builtin/runner.go +++ b/pkg/runner/builtin/runner.go @@ -118,6 +118,7 @@ func (r *Runner) Run(w *queue.Work) error { Netrc: w.Netrc, Yaml: w.Yaml, Build: task, + Env: w.Env, } in, err := json.Marshal(work) if err != nil { diff --git a/pkg/runner/builtin/worker.go b/pkg/runner/builtin/worker.go index 81710be5d..27539bce3 100644 --- a/pkg/runner/builtin/worker.go +++ b/pkg/runner/builtin/worker.go @@ -58,6 +58,7 @@ type work struct { Keys *common.Keypair `json:"keys"` Netrc *common.Netrc `json:"netrc"` Yaml []byte `json:"yaml"` + Env []string `json:"env"` } type worker struct {