diff --git a/pipeline/build/build.go b/pipeline/build/build.go index f04477c1c..3675f7709 100644 --- a/pipeline/build/build.go +++ b/pipeline/build/build.go @@ -58,6 +58,9 @@ func buildWithDefaults(ctx *context.Context, build config.Build) config.Build { if build.Binary == "" { build.Binary = ctx.Config.Release.GitHub.Name } + for k, v := range build.Env { + build.Env[k] = os.ExpandEnv(v) + } return builders.For(build.Lang).WithDefaults(build) } diff --git a/pipeline/build/build_test.go b/pipeline/build/build_test.go index 89a050dba..f9a58d30c 100644 --- a/pipeline/build/build_test.go +++ b/pipeline/build/build_test.go @@ -165,6 +165,24 @@ func TestDefaultNoBuilds(t *testing.T) { assert.NoError(t, Pipe{}.Default(ctx)) } +func TestDefaultExpandEnv(t *testing.T) { + assert.NoError(t, os.Setenv("BAR", "FOOBAR")) + var ctx = &context.Context{ + Config: config.Project{ + Builds: []config.Build{ + { + Env: []string{ + "FOO=bar_$BAR", + }, + }, + }, + }, + } + assert.NoError(t, Pipe{}.Default(ctx)) + var env = ctx.Config.Builds[0].Env[0] + assert.Equal(t, "FOO=bar_FOOBAR", env) +} + func TestDefaultEmptyBuild(t *testing.T) { var ctx = &context.Context{ Config: config.Project{