shell¶
Operation to run an arbitrary shell command.
Example¶
The following example uses the shell operation to perform two different operations:
First, it uses grep to find a file in the git repo starting with a __version__, then
it calls echo to display the result:
examples/operations/shell.yml¶steps:
"Find file containing __version__":
name: shell
cmd: "grep '^__version__' `git ls-files` -ls"
output_var: "version_file"
# Grep raises errors on many common operations so just ignore them:
ignore_error_code: true
opconfig:
# Save to "template_variables" namespace for use when rendering message:
output_namespace: "template_variables"
"Display result":
name: shell
cmd:
- "echo"
- "Version info can be found in {{ qwikstart.version_file }}"
Note that this uses two different signatures to define the shell cmd: The grep
operation defines the entire command as a string, while the echo command defines each
part of the command as an item in a list.
In order to render the context variable using the echo command, the version_file
is saved to the template_variables namespace by defining
output_namespace = "template_variables". See Understanding operations more
info.
Required context¶
cmdCommand or list of command arguments to run.
Optional context¶
echo_outputdefault:
TrueToggle display of output to terminal.
ignore_error_codedefault:
FalseToggle check for error code returned by shell operation.
output_processordefault:
'strip'Processor to run on output
dict_keys(['noop', 'strip'])output_vardefault:
NoneVariable name in which output is stored.
template_variablesDictionary of variables available when rendering the file template.
template_variable_prefixdefault:
'qwikstart'Template variables will be nested in this namespace when rendering; e.g:
{{<template_variable_prefix>.your_template_variable}}
Output¶
This operation can define arbitrary output in a variable defined by output_var.