From 317c85859817e158f76832206b21144375b791a6 Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Thu, 23 Dec 2021 15:59:20 +0530 Subject: [PATCH] Set parent process env in steps running on host VM (#39) --- engine/engine.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/engine/engine.go b/engine/engine.go index c0f30001..eba5a900 100644 --- a/engine/engine.go +++ b/engine/engine.go @@ -83,6 +83,15 @@ func (e *Engine) Run(ctx context.Context, step *spec.Step, output io.Writer) (*r e.mu.Unlock() envs := make(map[string]string) + if step.Image == "" { + // Set parent process envs in case step is executed directly on the VM. + // This sets the PATH environment variable (in case it is set on parent process) on sub-process executing the step. + for _, e := range os.Environ() { + if i := strings.Index(e, "="); i >= 0 { + envs[e[:i]] = e[i+1:] + } + } + } for k, v := range cfg.Envs { envs[k] = v }