diff --git a/internal/runconfig/runconfig.go b/internal/runconfig/runconfig.go index a695f94..b7cf301 100644 --- a/internal/runconfig/runconfig.go +++ b/internal/runconfig/runconfig.go @@ -26,6 +26,10 @@ import ( errors "golang.org/x/xerrors" ) +const ( + defaultShell = "/bin/sh -e" +) + func genRuntime(c *config.Config, ce *config.Runtime, variables map[string]string) *rstypes.Runtime { containers := []*rstypes.Container{} for _, cc := range ce.Containers { @@ -206,6 +210,10 @@ func GenRunConfigTasks(uuid util.UUIDGenerator, c *config.Config, runName string DockerRegistriesAuth: make(map[string]rstypes.DockerRegistryAuth), } + if t.Shell == "" { + t.Shell = defaultShell + } + if c.DockerRegistriesAuth != nil { for regname, auth := range c.DockerRegistriesAuth { t.DockerRegistriesAuth[regname] = rstypes.DockerRegistryAuth{ diff --git a/internal/runconfig/runconfig_test.go b/internal/runconfig/runconfig_test.go index 92f7bd4..39ee913 100644 --- a/internal/runconfig/runconfig_test.go +++ b/internal/runconfig/runconfig_test.go @@ -801,6 +801,7 @@ func TestGenRunConfig(t *testing.T) { }, }, }, + Shell: "/bin/sh -e", Environment: map[string]string{ "ENV01": "ENV01", "ENVFROMVARIABLE01": "VARVALUE01", @@ -876,6 +877,7 @@ func TestGenRunConfig(t *testing.T) { }, }, }, + Shell: "/bin/sh -e", Environment: map[string]string{}, Steps: rstypes.Steps{ &rstypes.RunStep{BaseStep: rstypes.BaseStep{Type: "run", Name: "command01"}, Command: "command01", Environment: map[string]string{}}, @@ -973,6 +975,7 @@ func TestGenRunConfig(t *testing.T) { }, }, }, + Shell: "/bin/sh -e", Environment: map[string]string{}, Steps: rstypes.Steps{ &rstypes.RunStep{BaseStep: rstypes.BaseStep{Type: "run", Name: "command01"}, Command: "command01", Environment: map[string]string{}}, diff --git a/internal/services/executor/executor.go b/internal/services/executor/executor.go index c60d2a7..be400e3 100644 --- a/internal/services/executor/executor.go +++ b/internal/services/executor/executor.go @@ -109,6 +109,8 @@ func (e *Executor) doRunStep(ctx context.Context, s *types.RunStep, t *types.Exe } defer outf.Close() + // TODO(sgotti) this line is used only for old runconfig versions that don't + // set a task default shell in the runconfig shell := defaultShell if t.Shell != "" { shell = t.Shell