Skip to content

Latest commit

 

History

History
80 lines (60 loc) · 2.85 KB

File metadata and controls

80 lines (60 loc) · 2.85 KB
title description ms.topic ms.assetid ms.custom ms.date monikerRange
Bash task
Run a Bash script on macOS, Linux, or Windows
reference
6C731C3C-3C68-459A-A5C9-BDE6E6595B5B
seodec18
06/09/2020
azure-devops

Bash task

Azure Pipelines

Use this task to run a Bash script on macOS, Linux, or Windows.

::: moniker range="> tfs-2018"

YAML snippet

[!INCLUDE temp]

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

::: moniker-end

Arguments

Argument Description
targetType
Type
(Optional) Target script type: File Path or Inline
Default value: filePath
filePath
Script Path
(Required) Path of the script to execute. Must be a fully qualified path or relative to $(System.DefaultWorkingDirectory).
arguments
Arguments
(Optional) Arguments passed to the Bash script.
script
Script
(Required, if Type is inline) Contents of the script
Default value: "# Write your commands here\n\necho 'Hello world'\n"
workingDirectory
Working Directory
(Optional) Specify the working directory in which you want to run the command. If you leave it empty, the working directory is $(Build.SourcesDirectory)
failOnStderr
Fail on standard error
(Optional) If this is true, this task will fail if any errors are written to stderr.
Default value: false
noProfile
Don't load the system-wide startup/initialization files
(Optional) Don't load the system-wide startup file /etc/profile or any of the personal initialization files
noRc
Don't read the ~/.bashrc file
(Optional) If this is true, the task will not process .bashrc from the user's home directory.
Default value: true
env
Environment variables
(Optional) 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:
steps:
- task: Bash@3
  inputs:
    targetType: 'inline'
    script: echo $MYSECRET
  env:
    MYSECRET: $(Foo)

This is equivalent to:

steps:
- script: echo $MYSECRET
  env:
    MYSECRET: $(Foo)

The Bash task will find the first Bash implementation on your system. Running which bash on Linux/macOS or where bash on Windows will give you an idea of which one it'll select.

::: moniker range=">= azure-devops-2019"

Bash scripts checked into the repo should be set executable (chmod +x). Otherwise, the task will show a warning and source the file instead.

::: moniker-end

Open source

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