From 90681986feab68ee1e3940d87ad07549bf8da2ff Mon Sep 17 00:00:00 2001 From: Martin Bruse Date: Wed, 26 Feb 2014 14:18:09 +0100 Subject: [PATCH] More discriminate env setting --- pkg/build/build.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pkg/build/build.go b/pkg/build/build.go index b95d75dd6..812844521 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -414,10 +414,18 @@ func (b *Builder) writeDockerfile(dir string) error { dockerfile.WriteEnv("CI", "true") dockerfile.WriteEnv("DRONE", "true") - dockerfile.WriteEnv("DRONE_BRANCH", b.Repo.Branch) - dockerfile.WriteEnv("DRONE_COMMIT", b.Repo.Commit) - dockerfile.WriteEnv("DRONE_PR", b.Repo.PR) - dockerfile.WriteEnv("DRONE_BUILD_DIR", b.Repo.Dir) + if b.Repo.Branch != "" { + dockerfile.WriteEnv("DRONE_BRANCH", b.Repo.Branch) + } + if b.Repo.Commit != "" { + dockerfile.WriteEnv("DRONE_COMMIT", b.Repo.Commit) + } + if b.Repo.PR != "" { + dockerfile.WriteEnv("DRONE_PR", b.Repo.PR) + } + if b.Repo.Dir != "" { + dockerfile.WriteEnv("DRONE_BUILD_DIR", b.Repo.Dir) + } dockerfile.WriteAdd("proxy.sh", "/etc/drone.d/") dockerfile.WriteEntrypoint("/bin/bash -e /usr/local/bin/drone")