1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-15 18:57:01 +00:00

Change handling of ExtraPath (#406)

To make the handling of ExtraPath portable append it to the front of the
PATH when it exists, instead of always changing the script.
This commit is contained in:
Wink Saville 2020-11-02 13:56:20 -08:00 committed by GitHub
parent 4282e53b56
commit 4119f3b80d

View file

@ -92,6 +92,11 @@ func (sc *StepContext) setupEnv() common.Executor {
env = mergeMaps(rc.GetEnv(), step.GetEnv())
}
if (rc.ExtraPath != nil) && (len(rc.ExtraPath) > 0) {
s := append(rc.ExtraPath, os.Getenv("PATH"))
env["PATH"] = strings.Join(s, string(os.PathSeparator))
}
for k, v := range env {
env[k] = rc.ExprEval.Interpolate(v)
}
@ -106,11 +111,7 @@ func (sc *StepContext) setupShellCommand() common.Executor {
step := sc.Step
return func(ctx context.Context) error {
var script strings.Builder
_, err := script.WriteString(fmt.Sprintf("PATH=\"%s:${PATH}\"\n", strings.Join(rc.ExtraPath, ":")))
if err != nil {
return err
}
var err error
if step.WorkingDirectory == "" {
step.WorkingDirectory = rc.Run.Job().Defaults.Run.WorkingDirectory