diff --git a/pipeline/backend/common/script.go b/pipeline/backend/common/script.go index 9da62b92d..e335983d9 100644 --- a/pipeline/backend/common/script.go +++ b/pipeline/backend/common/script.go @@ -18,21 +18,19 @@ import ( "encoding/base64" ) -func GenerateContainerConf(commands []string, goos string) (env map[string]string, entry []string, cmd string) { +func GenerateContainerConf(commands []string, goos string) (env map[string]string, entry []string) { env = make(map[string]string) if goos == "windows" { env["CI_SCRIPT"] = base64.StdEncoding.EncodeToString([]byte(generateScriptWindows(commands))) env["HOME"] = "c:\\root" env["SHELL"] = "powershell.exe" - entry = []string{"powershell", "-noprofile", "-noninteractive", "-command"} - cmd = "[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Env:CI_SCRIPT)) | iex" + entry = []string{"powershell", "-noprofile", "-noninteractive", "-command", "[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Env:CI_SCRIPT)) | iex"} } else { env["CI_SCRIPT"] = base64.StdEncoding.EncodeToString([]byte(generateScriptPosix(commands))) env["HOME"] = "/root" env["SHELL"] = "/bin/sh" - entry = []string{"/bin/sh", "-c"} - cmd = "echo $CI_SCRIPT | base64 -d | /bin/sh -e" + entry = []string{"/bin/sh", "-c", "echo $CI_SCRIPT | base64 -d | /bin/sh -e"} } - return env, entry, cmd + return env, entry } diff --git a/pipeline/backend/docker/convert.go b/pipeline/backend/docker/convert.go index 1e4ad589b..1ca70b934 100644 --- a/pipeline/backend/docker/convert.go +++ b/pipeline/backend/docker/convert.go @@ -46,7 +46,7 @@ func (e *docker) toConfig(step *types.Step) *container.Config { maps.Copy(configEnv, step.Environment) if len(step.Commands) != 0 { - env, entry, cmd := common.GenerateContainerConf(step.Commands, e.info.OSType) + env, entry := common.GenerateContainerConf(step.Commands, e.info.OSType) for k, v := range env { configEnv[k] = v } @@ -54,7 +54,6 @@ func (e *docker) toConfig(step *types.Step) *container.Config { entry = step.Entrypoint } config.Entrypoint = entry - config.Cmd = []string{cmd} } if len(configEnv) != 0 { diff --git a/pipeline/backend/kubernetes/pod.go b/pipeline/backend/kubernetes/pod.go index 7a70aa5b0..4d66058d9 100644 --- a/pipeline/backend/kubernetes/pod.go +++ b/pipeline/backend/kubernetes/pod.go @@ -145,12 +145,11 @@ func podContainer(step *types.Step, podName, goos string, options BackendOptions } if len(step.Commands) != 0 { - scriptEnv, command, args := common.GenerateContainerConf(step.Commands, goos) + scriptEnv, command := common.GenerateContainerConf(step.Commands, goos) if len(step.Entrypoint) > 0 { command = step.Entrypoint } container.Command = command - container.Args = []string{args} maps.Copy(step.Environment, scriptEnv) }