Shell Command
The shell command executes shell commands with full environment control and configurable exit code handling.
Attributes
Required
type: "shell": Identifies this as a shell commandname: Descriptive name for the commandcommand_line: The shell command to execute
Optional
working_directory: Directory to execute the command in (inherits from parent if not specified)env: Environment variables as key-value pairsruns_on_condition: When to run (success,error,always,exit-codes)runs_on_exit_codes: Specific exit codes that trigger executionsuccess_exit_codes: Exit codes indicating success (defaults to[0])skip_exit_codes: Exit codes that skip remaining commands
Basic Example
Complete Example
Environment Variables
Environment variables are inherited from:
- The system environment
- Parent command’s environment
- The command’s own
envsettings (takes precedence)
Exit Code Handling
Success Codes
Define which exit codes indicate success:
Skip Codes
Exit codes that skip remaining commands in the batch:
Using Redirection
Porch captures stdout and stderr automatically. Use redirection to control output:
By default, stderr is displayed in results if the step fails or returns a skippable exit code.
Multi-line Commands
Use YAML multi-line strings for complex commands:
Conditional Execution
Run commands based on previous results:
Common Patterns
Build with Environment Variables
Script Execution
Pipeline with Skip
Best Practices
- Use explicit exit codes: Define
success_exit_codesfor commands with non-standard success codes - Set working directory: Use
working_directoryinstead ofcdin commands - Use environment variables: Prefer
envover hardcoded values - Redirect important messages: Send warnings and skip messages to stderr
- Use multi-line for complex scripts: Makes commands more readable
- Handle errors gracefully: Use
skip_exit_codesfor optional steps
Related
- Flow Control - Learn about skip codes and conditional execution
- Path Inheritance - Understand how working directories are resolved
- Serial Command - Execute shell commands sequentially
- Parallel Command - Execute shell commands concurrently