runshell

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

README

run_shell Task

Description

The run_shell task executes a series of commands within a shell environment. This task is especially useful for complex operations that require executing a shell script or a sequence of commands within a specific shell.

Configuration Parameters

  • shell:
    Specifies the type of shell to use for running the commands. Common shells include sh, bash, zsh, etc. The default is sh.

  • 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.

  • command:
    The command or series of commands to be executed in the shell. This can be a single command or a full script. The commands should be provided as a single string, and if multiple commands are needed, they can be separated by the appropriate shell command separator (e.g., newlines or semicolons in sh or bash).

Output Handling

The run_shell task scans the standard output (stdout) of the shell script for specific triggers that enable actions from within the script.
For instance, a script can set a variable in the current task context by outputting a formatted string.
An example of setting a variable USER_VAR to "new value" would be:

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

Default settings for the run_shell task:

- name: run_shell
  config:
    shell: sh
    envVars: {}
    command: ""

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TaskName       = "run_shell"
	TaskDescriptor = &types.TaskDescriptor{
		Name:        TaskName,
		Description: "Runs commands in a shell.",
		Config:      DefaultConfig(),
		NewTask:     NewTask,
	}
)

Functions

func NewTask

func NewTask(ctx *types.TaskContext, options *types.TaskOptions) (types.Task, error)

Types

type Config

type Config struct {
	Shell   string            `yaml:"shell" json:"shell"`
	EnvVars map[string]string `yaml:"envVars" json:"envVars"`
	Command string            `yaml:"command" json:"command"`
}

func DefaultConfig

func DefaultConfig() Config

func (*Config) Validate

func (c *Config) Validate() error

type Task

type Task struct {
	// contains filtered or unexported fields
}

func (*Task) Config

func (t *Task) Config() interface{}

func (*Task) Description

func (t *Task) Description() string

func (*Task) Execute

func (t *Task) Execute(ctx context.Context) error

func (*Task) LoadConfig

func (t *Task) LoadConfig() error

func (*Task) Logger

func (t *Task) Logger() logrus.FieldLogger

func (*Task) Name

func (t *Task) Name() string

func (*Task) Timeout

func (t *Task) Timeout() time.Duration

func (*Task) Title

func (t *Task) Title() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL