diff --git a/pipeline/build/build.go b/pipeline/build/build.go index 37f8d4404..495cfaa2a 100644 --- a/pipeline/build/build.go +++ b/pipeline/build/build.go @@ -57,7 +57,7 @@ func runHook(env []string, hook string) error { } log.Println("Running hook", hook) cmd := strings.Fields(hook) - return run(env, runtimeTarget, cmd) + return run(runtimeTarget, cmd, env) } func build(ctx *context.Context, name string, target buildTarget) error { @@ -76,10 +76,10 @@ func build(ctx *context.Context, name string, target buildTarget) error { return err } cmd = append(cmd, "-ldflags="+flags, "-o", output, ctx.Config.Build.Main) - return run(ctx.Config.Build.Env, target, cmd) + return run(target, cmd, ctx.Config.Build.Env) } -func run(env []string, target buildTarget, command []string) error { +func run(target buildTarget, command, env []string) error { cmd := exec.Command(command[0], command[1:]...) cmd.Env = append(cmd.Env, os.Environ()...) cmd.Env = append(cmd.Env, env...) diff --git a/pipeline/build/build_test.go b/pipeline/build/build_test.go index fc179d720..3053e4a4b 100644 --- a/pipeline/build/build_test.go +++ b/pipeline/build/build_test.go @@ -19,11 +19,11 @@ func TestPipeDescription(t *testing.T) { } func TestRun(t *testing.T) { - assert.NoError(t, run(emptyEnv, runtimeTarget, []string{"go", "list", "./..."})) + assert.NoError(t, run(runtimeTarget, []string{"go", "list", "./..."}, emptyEnv)) } func TestRunInvalidCommand(t *testing.T) { - assert.Error(t, run(emptyEnv, runtimeTarget, []string{"gggggo", "nope"})) + assert.Error(t, run(runtimeTarget, []string{"gggggo", "nope"}, emptyEnv)) } func TestBuild(t *testing.T) {