@@ -134,6 +134,7 @@ type AgentStartConfig struct {
134134 PluginsPath string `cli:"plugins-path" normalize:"filepath"`
135135
136136 Shell string `cli:"shell"`
137+ HooksShell string `cli:"hooks-shell"`
137138 BootstrapScript string `cli:"bootstrap-script" normalize:"commandpath"`
138139 NoPTY bool `cli:"no-pty"`
139140
@@ -306,7 +307,7 @@ func (asc AgentStartConfig) Features(ctx context.Context) []string {
306307}
307308
308309func DefaultShell () string {
309- // https://github.com/golang/go/blob/master/src/go/build /syslist.go#L7
310+ // https://github.com/golang/go/blob/master/src/internal/syslist /syslist.go#L17
310311 switch runtime .GOOS {
311312 case "windows" :
312313 return `C:\Windows\System32\CMD.exe /S /C`
@@ -434,6 +435,11 @@ var AgentStartCommand = cli.Command{
434435 Usage : "The shell command used to interpret build commands, e.g /bin/bash -e -c" ,
435436 EnvVar : "BUILDKITE_SHELL" ,
436437 },
438+ cli.StringFlag {
439+ Name : "hooks-shell" ,
440+ Usage : "The shell command used to interpret hooks commands, e.g pwsh -Command" ,
441+ EnvVar : "BUILDKITE_HOOKS_SHELL" ,
442+ },
437443 cli.StringFlag {
438444 Name : "queue" ,
439445 Usage : "The queue the agent will listen to for jobs. If not set, the agent will use the default queue. Overwrites the queue tag in the agent's tags" ,
@@ -1071,6 +1077,7 @@ var AgentStartCommand = cli.Command{
10711077 WriteJobLogsToStdout : cfg .WriteJobLogsToStdout ,
10721078 LogFormat : cfg .LogFormat ,
10731079 Shell : cfg .Shell ,
1080+ HooksShell : cfg .HooksShell ,
10741081 RedactedVars : cfg .RedactedVars ,
10751082 AcquireJob : cfg .AcquireJob ,
10761083 TracingBackend : cfg .TracingBackend ,
@@ -1548,7 +1555,7 @@ func agentLifecycleHook(hookName string, log logger.Logger, cfg AgentStartConfig
15481555
15491556 // run hooks
15501557 for _ , p = range hooks {
1551- script , err := sh .Script (p )
1558+ script , err := sh .Script (p , cfg . HooksShell )
15521559 if err != nil {
15531560 log .Error ("%q hook: %v" , hookName , err )
15541561 return err
0 commit comments