Skip to content

Commit

Permalink
Expand $PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
maximede committed Jun 13, 2019
1 parent bb20ef0 commit 821ae9f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion server/events/runtime/run_step_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (r *RunStepRunner) Run(ctx models.ProjectCommandContext, command string, pa
"HEAD_BRANCH_NAME": ctx.Pull.HeadBranch,
"HEAD_REPO_NAME": ctx.HeadRepo.Name,
"HEAD_REPO_OWNER": ctx.HeadRepo.Owner,
"PATH": fmt.Sprintf("$PATH:%s", r.TerraformBinDir),
"PATH": fmt.Sprintf(os.ExpandEnv("$PATH:%s"), r.TerraformBinDir),
"PLANFILE": filepath.Join(path, GetPlanFilename(ctx.Workspace, ctx.ProjectName)),
"PROJECT_NAME": ctx.ProjectName,
"PULL_AUTHOR": ctx.Pull.Author,
Expand All @@ -46,6 +46,8 @@ func (r *RunStepRunner) Run(ctx models.ProjectCommandContext, command string, pa
for key, val := range customEnvVars {
finalEnvVars = append(finalEnvVars, fmt.Sprintf("%s=%s", key, val))
}


cmd.Env = finalEnvVars
out, err := cmd.CombinedOutput()

Expand Down
4 changes: 3 additions & 1 deletion server/events/runtime/run_step_runner_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package runtime_test

import (
"fmt"
"os"
"strings"
"testing"

Expand Down Expand Up @@ -64,7 +66,7 @@ func TestRunStepRunner_Run(t *testing.T) {
ExpOut: "user_name=acme-user\n",
},{
Command: "echo $PATH",
ExpOut: "$PATH:/bin/dir\n",
ExpOut: fmt.Sprintf(os.ExpandEnv("$PATH%s"),":/bin/dir\n"),
},
}

Expand Down

0 comments on commit 821ae9f

Please sign in to comment.