diff --git a/pkg/coordinator/tasks/run_shell/README.md b/pkg/coordinator/tasks/run_shell/README.md index 6a11303..f2f75bd 100644 --- a/pkg/coordinator/tasks/run_shell/README.md +++ b/pkg/coordinator/tasks/run_shell/README.md @@ -9,6 +9,9 @@ The `run_shell` task executes a series of commands within a shell environment. T - **`shell`**:\ Specifies the type of shell to use for running the commands. Common shells include `sh`, `bash`, `zsh`, etc. The default is `sh`. +- **`shellArgs`**:\ + Additional arguments to pass to the shell. Example: `--login`. + - **`envVars`**:\ A dictionary specifying the environment variables to be used within the shell. Each key in this dictionary represents the name of an environment variable, and its corresponding value indicates the name of a variable from which the actual value should be read. \ For instance, if `envVars` is set as `{"PATH_VAR": "MY_PATH", "USER_VAR": "MY_USER"}`, the task will use the values of `MY_PATH` and `MY_USER` variables from the current task variable context as the values for `PATH_VAR` and `USER_VAR` within the shell. @@ -27,7 +30,7 @@ echo "::set-var USER_VAR new value" This feature allows the shell script to interact dynamically with the task context, modifying variables based on script execution. Please note that this feature is still under development and the format of these triggers may change in future versions of the tool. It's important to stay updated with the latest documentation and release notes for any modifications to this functionality. - + ### Defaults @@ -36,7 +39,8 @@ Default settings for the `run_shell` task: ```yaml - name: run_shell config: - shell: sh + shell: bash + shellArgs: [] envVars: {} command: "" ``` diff --git a/pkg/coordinator/tasks/run_shell/config.go b/pkg/coordinator/tasks/run_shell/config.go index 3878686..dc23bc3 100644 --- a/pkg/coordinator/tasks/run_shell/config.go +++ b/pkg/coordinator/tasks/run_shell/config.go @@ -3,14 +3,16 @@ package runshell import "errors" type Config struct { - Shell string `yaml:"shell" json:"shell"` - EnvVars map[string]string `yaml:"envVars" json:"envVars"` - Command string `yaml:"command" json:"command"` + Shell string `yaml:"shell" json:"shell"` + ShellArgs []string `yaml:"shellArgs" json:"shellArgs"` + EnvVars map[string]string `yaml:"envVars" json:"envVars"` + Command string `yaml:"command" json:"command"` } func DefaultConfig() Config { return Config{ - Shell: "bash", + Shell: "bash", + ShellArgs: []string{}, } } diff --git a/pkg/coordinator/tasks/run_shell/task.go b/pkg/coordinator/tasks/run_shell/task.go index 4798295..092953c 100644 --- a/pkg/coordinator/tasks/run_shell/task.go +++ b/pkg/coordinator/tasks/run_shell/task.go @@ -78,7 +78,7 @@ func (t *Task) Execute(ctx context.Context) error { cmdLogger.Info("running command") //nolint:gosec // ignore - command := exec.CommandContext(ctx, t.config.Shell) + command := exec.CommandContext(ctx, t.config.Shell, t.config.ShellArgs...) stdin, err := command.StdinPipe() if err != nil {