Use jobs.<job_id>.steps[*].shell
to override the default shell settings in the runner’s operating system.
You can use built-in shell
keywords, or else define a custom set of shell options.
The shell command that is run internally executes a temporary file that contains the commands specified in the run
keyword.
Supported platform |
|
Description |
Command run internally |
Linux |
unspecified |
Default shell on Linux platforms.
Note this runs a different command versus when |
|
All |
|
The default shell on non-Windows platforms. Falls back to |
|
All |
|
Runs the python command. |
|
Linux |
|
Fallback for Linux platforms if no shell is provided and |
|
Overriding the default shell on MacOS or Windows is not currently supported. Only Linux platforms are currently supported. |
Example usage
In the following example, each step displays the path.
-
The first step runs using Bash.
-
The second step runs using the Python command.
steps: - name: Run using Bash uses: docker://bash:5 shell: bash run: echo $PATH - name: Run an inline Python script uses: docker://python:3 shell: python run: | import os print(os.environ['PATH'])
In the following example, both echo
commands run in the same shell.
my-job: steps: - uses: docker://alpine:3.18 shell: bash run: | echo 'Hello' echo 'world'
Exit codes and error action preference
bash/sh
is a default executed by CloudBees platform-hosted runners and is provided for built-in shell keywords.
CloudBees recommends that you adhere to the following usage guidelines for the bash/sh
default:
-
Fail-fast behavior is enforced using
set -e
for bothsh
andbash
by default. -
sh
-like shells exit with the exit code of the last command executed in a script, which is also the default behavior for actions. The runner reports the status of the step as fail/succeed based on this exit code.