Skip to content

Commit

Permalink
fix host worker run when step name contains spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
zc2638 committed Mar 12, 2024
1 parent e90c41e commit 8f9535b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/worker/hooks/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"os"
"os/exec"
"path/filepath"
"strings"

"github.com/zc2638/wslog"

Expand Down Expand Up @@ -49,7 +50,8 @@ func (h *host) Begin(ctx context.Context, spec *worker.Workflow) error {
args = step.Shell[1:]
}
cmdData := shell.Script(step.Command)
fp := filepath.Join(scriptPath, step.Name+shell.Suffix)
stepName := strings.ReplaceAll(step.Name, " ", "_")
fp := filepath.Join(scriptPath, stepName+shell.Suffix)
if err := os.WriteFile(fp, []byte(cmdData), os.ModePerm); err != nil {
log.Error("cannot write file", "error", err)
return err
Expand Down
3 changes: 3 additions & 0 deletions core/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ func execute(
stepLog.Debug("received exit code 78. early exit.")
step.Phase = v1.PhaseSkipped
failed = true
} else if state.ExitCode > 0 {
step.Phase = v1.PhaseFailed
failed = true
}
}

Expand Down

0 comments on commit 8f9535b

Please sign in to comment.