Bash task

Azure Pipelines

Use this task in a build or release pipeline to run a Bash script on macOS, Linux, or Windows.

YAML snippet

# Bash
# Run a Bash script on macOS, Linux, or Windows
- task: Bash@3
  inputs:
    #targetType: 'filePath' # Optional. Options: filePath, inline
    #filePath: # Required when targetType == FilePath
    #arguments: # Optional
    #script: '# Write your commands here# Use the environment variables input below to pass secret variables to this script' # Required when targetType == Inline
    #workingDirectory: # Optional
    #failOnStderr: false # Optional

The Bash task also has a shortcut syntax in YAML:

- bash: # script path or inline
  workingDirectory: #
  displayName: #
  failOnStderr: #
  env:  # mapping of environment variables to add

Arguments

ArgumentDescription
TypeSets whether this is an inline script or a path to a .sh file
File pathPath of the script to execute. Must be a fully qualified path or relative to $(System.DefaultWorkingDirectory). Required if Type is filePath.
ArgumentsArguments passed to the Bash script.
ScriptContents of the script. Required if Type is inline
Working DirectorySpecify the working directory in which you want to run the command. If you leave it empty, the working directory is $(Build.SourcesDirectory).
Fail on standard error If this is true, this task will fail if any errors are written to stderr.
Env[ironment variables] A list of additional items to map into the process's environment. For example, secret variables are not automatically mapped. If you have a secret variable called Foo, you can map it in like this:

yaml - script: echo $MYSECRET env: MySecret: $(Foo)
Control options

Open source

This task is open source on GitHub. Feedback and contributions are welcome.