Use this task to run a shell script using bash
.
# Shell script v2
# Run a shell script using Bash.
- task: ShellScript@2
inputs:
scriptPath: # string. Required. Script Path.
#args: # string. Arguments.
# Advanced
#disableAutoCwd: false # boolean. Specify Working Directory. Default: false.
#cwd: # string. Optional. Use when disableAutoCwd = true. Working Directory.
#failOnStandardError: false # boolean. Fail on Standard Error. Default: false.
Inputs
scriptPath
- Script Pathstring
. Required.
Specifies the relative path from the repo root to the shell script file that you want to run.
args
- Argumentsstring
.
Specifies the arguments that you want to pass to the script.
disableAutoCwd
- Specify Working Directoryboolean
. Default value: false
.
Specifies the working directory where the task runs the script. If the value is left empty, the task defaults to the folder where the script is located.
cwd
- Working Directorystring
. Optional. Use when disableAutoCwd = true
.
Specifies the working directory where the script is run. If the value is left empty, the task uses the root of the repo (build) or artifacts (release), which is $(System.DefaultWorkingDirectory)
.
failOnStandardError
- Fail on Standard Errorboolean
. Default value: false
.
If the value is true
, the task will fail if errors are written to the StandardError stream.
All tasks have control options in addition to their task inputs. For more information, see Control options and common task properties.
Output variablesNone.
Where can I learn about Bash scripts?To learn more about defining build variables in a script, see Define and modify your build variables in a script.
To learn more about defining release variables in a script, see Define and modify your release variables in a script
ExamplesCreate test.sh
at the root of your repo. We recommend creating this file from a Linux environment (such as a real Linux machine or Windows Subsystem for Linux) so that line endings are correct. Also, don't forget to chmod +x test.sh
before you commit it.
#!/bin/bash
echo "Hello World"
echo "AGENT_WORKFOLDER is $AGENT_WORKFOLDER"
echo "AGENT_WORKFOLDER contents:"
ls -1 $AGENT_WORKFOLDER
echo "AGENT_BUILDDIRECTORY is $AGENT_BUILDDIRECTORY"
echo "AGENT_BUILDDIRECTORY contents:"
ls -1 $AGENT_BUILDDIRECTORY
echo "SYSTEM_HOSTTYPE is $SYSTEM_HOSTTYPE"
echo "Over and out."
Add the following task to your pipeline to run the previous script.
- task: ShellScript@2
inputs:
scriptPath: 'test.sh'
Requirements Requirement Description Pipeline types YAML, Classic build, Classic release Runs on Agent, DeploymentGroup Demands Self-hosted agents must have capabilities that match the following demands to run jobs that use this task: sh Capabilities This task does not satisfy any demands for subsequent tasks in the job. Command restrictions Any Settable variables Any Agent version All supported agent versions. Task category Utility
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4