From e7e6b2c6085584b3440f99aac55af5e4081d1b1f Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Wed, 13 Aug 2014 21:37:56 -0700 Subject: [PATCH] added code to append private environment variables for non-PRs --- server/worker/worker.go | 17 +++++++++++++---- shared/build/script/script.go | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/server/worker/worker.go b/server/worker/worker.go index 7a7b15d0..c2bbae59 100644 --- a/server/worker/worker.go +++ b/server/worker/worker.go @@ -5,6 +5,7 @@ import ( "path/filepath" "time" + "github.com/drone/drone/plugin/notify" "github.com/drone/drone/server/database" "github.com/drone/drone/server/pubsub" "github.com/drone/drone/shared/build" @@ -103,6 +104,15 @@ func (w *worker) Execute(r *model.Request) { log.Printf("Error parsing YAML for %s/%s, Err: %s", r.Repo.Owner, r.Repo.Name, err.Error()) } + // append private parameters to the environment + // variable section of the .drone.yml file, iff + // this is not a pull request (for security purposes) + if params != nil && len(r.Commit.PullRequest) == 0 { + for k, v := range params { + script.Env = append(script.Env, k+"="+v) + } + } + path := r.Repo.Host + "/" + r.Repo.Owner + "/" + r.Repo.Name repo := &repo.Repo{ Name: path, @@ -125,8 +135,9 @@ func (w *worker) Execute(r *model.Request) { // send all "started" notifications if script.Notifications != nil { - script.Notifications.Send(r) + script.Notifications = ¬ify.Notification{} } + script.Notifications.Send(r) // create an instance of the Docker builder builder := build.New(dockerClient) @@ -166,7 +177,5 @@ func (w *worker) Execute(r *model.Request) { commitc.Publish(r) // send all "finished" notifications - if script.Notifications != nil { - script.Notifications.Send(r) - } + script.Notifications.Send(r) } diff --git a/shared/build/script/script.go b/shared/build/script/script.go index c1a2e074..9f7d2d6e 100644 --- a/shared/build/script/script.go +++ b/shared/build/script/script.go @@ -76,7 +76,7 @@ type Build struct { Deploy *deploy.Deploy `yaml:"deploy,omitempty"` Publish *publish.Publish `yaml:"publish,omitempty"` - Notifications *notify.Notification `yaml:"notify"` + Notifications *notify.Notification `yaml:"notify,omitempty"` // Git specified git-specific parameters, such as // the clone depth and path