jobs.<job_id>.steps[*].shell

2 minute read

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

shell parameter

Description

Command run internally

Linux

unspecified

Default shell on Linux platforms. Note this runs a different command versus when bash is explicitly specified. If bash is not found in the path, this is interpreted as sh.

bash -e {0}

All

bash

The default shell on non-Windows platforms. Falls back to sh.

bash --noprofile --norc -eo pipefail {0}

All

python

Runs the python command.

python {0}

Linux

sh

Fallback for Linux platforms if no shell is provided and bash is not found in the path.

sh -e {0}

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 both sh and bash 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.