From fd2b4b71baad011526f9cd7f797792e2342866f9 Mon Sep 17 00:00:00 2001 From: Joachim Hill-Grannec Date: Fri, 10 Jun 2016 17:02:00 -0700 Subject: [PATCH 1/2] update to initialize the Environment map --- agent/agent.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/agent/agent.go b/agent/agent.go index d3a83f8a8..2c48ff3a1 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -210,6 +210,9 @@ func (a *Agent) exec(spec *yaml.Config, payload *queue.Work, cancel <-chan bool) } // updates the build status passed into each container. I realize this is // a bit out of place and will work to resolve. + if pipeline.Head().Environment == nil { + pipeline.Head().Environment = make(map[string]string) + } pipeline.Head().Environment["DRONE_BUILD_STATUS"] = status if !pipeline.Head().Constraints.Match( From 7e5a6ec9fb884531ebab89d79ec837759bdf0278 Mon Sep 17 00:00:00 2001 From: Joachim Hill-Grannec Date: Fri, 10 Jun 2016 20:46:13 -0700 Subject: [PATCH 2/2] Allowing for services with no environment defined. --- agent/agent.go | 3 --- yaml/transform/environ.go | 6 +++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index 2c48ff3a1..d3a83f8a8 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -210,9 +210,6 @@ func (a *Agent) exec(spec *yaml.Config, payload *queue.Work, cancel <-chan bool) } // updates the build status passed into each container. I realize this is // a bit out of place and will work to resolve. - if pipeline.Head().Environment == nil { - pipeline.Head().Environment = make(map[string]string) - } pipeline.Head().Environment["DRONE_BUILD_STATUS"] = status if !pipeline.Head().Constraints.Match( diff --git a/yaml/transform/environ.go b/yaml/transform/environ.go index b00c051ba..582518b2d 100644 --- a/yaml/transform/environ.go +++ b/yaml/transform/environ.go @@ -16,7 +16,11 @@ var ( // Environ transforms the steps in the Yaml pipeline to include runtime // environment variables. func Environ(c *yaml.Config, envs map[string]string) error { - for _, p := range c.Pipeline { + var images []*yaml.Container + images = append(images, c.Pipeline...) + images = append(images, c.Services...) + + for _, p := range images { if p.Environment == nil { p.Environment = map[string]string{} }