From 7bb3358b63f4635b15e6d9a4bd75bf06f5975785 Mon Sep 17 00:00:00 2001 From: Martin Bruse Date: Wed, 26 Feb 2014 13:43:13 +0100 Subject: [PATCH 1/2] Added more Environment variables. --- pkg/build/build.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/build/build.go b/pkg/build/build.go index f5e73ecf8..b95d75dd6 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -412,6 +412,13 @@ func (b *Builder) writeDockerfile(dir string) error { dockerfile.WriteRun("echo 'StrictHostKeyChecking no' > /root/.ssh/config") } + 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) + dockerfile.WriteAdd("proxy.sh", "/etc/drone.d/") dockerfile.WriteEntrypoint("/bin/bash -e /usr/local/bin/drone") From 90681986feab68ee1e3940d87ad07549bf8da2ff Mon Sep 17 00:00:00 2001 From: Martin Bruse Date: Wed, 26 Feb 2014 14:18:09 +0100 Subject: [PATCH 2/2] 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")