From d757618b070b98ac31bfd5bf3409d0acbb500bf5 Mon Sep 17 00:00:00 2001 From: Jacob Tolar Date: Wed, 15 Jun 2022 01:14:37 -0500 Subject: [PATCH] feat: add SD_STEP_NAME env variable --- executor/executor.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/executor/executor.go b/executor/executor.go index 2579520..20008d0 100644 --- a/executor/executor.go +++ b/executor/executor.go @@ -138,9 +138,11 @@ func doRunSetupCommand(emitter screwdriver.Emitter, f *os.File, r io.Reader, set return nil } -func doRunCommand(guid, path string, emitter screwdriver.Emitter, f *os.File, fReader io.Reader) (int, error) { +func doRunCommand(guid, path string, emitter screwdriver.Emitter, f *os.File, fReader io.Reader, stepName string) (int, error) { executionCommand := []string{ "export SD_STEP_ID=" + guid, + // escape not necessary because step name is limited to [A-Za-z0-9_-] + ";export SD_STEP_NAME=" + stepName, ";. " + path, ";echo", ";echo " + guid + " $?\n", @@ -336,7 +338,7 @@ func Run(path string, env []string, emitter screwdriver.Emitter, build screwdriv fReader := bufio.NewReader(f) go func() { - runCode, rcErr := doRunCommand(guid, stepFilePath, emitter, f, fReader) + runCode, rcErr := doRunCommand(guid, stepFilePath, emitter, f, fReader, cmd.Name) // exit code & errors from doRunCommand eCode <- runCode runErr <- rcErr