Use this task to run a Windows .bat
or .cmd
script. Optionally, the .bat
or .cmd
script can permanently modify environment variables.
# Batch script v1
# Run a Windows command or batch script and optionally allow it to change the environment.
- task: BatchScript@1
inputs:
filename: # string. Required. Path.
#arguments: # string. Arguments.
#modifyEnvironment: False # boolean. Modify Environment. Default: False.
# Advanced
#workingFolder: # string. Working folder.
#failOnStandardError: false # boolean. Fail on Standard Error. Default: false.
Inputs
filename
- Pathstring
. Required.
The path of the .cmd
or .bat
script to execute. This should be a fully qualified path or one relative to the default working directory. (Please note that the working directory could differ from workingFolder
, which could be specified for this task.)
arguments
- Argumentsstring
.
The arguments passed to the .cmd
or .bat
script.
modifyEnvironment
- Modify Environmentboolean
. Default value: False
.
Determines whether environment variable modifications will affect subsequent tasks.
workingFolder
- Working folderstring
.
The current working directory when a script is run. This defaults to the folder where the script is located.
failOnStandardError
- Fail on Standard Errorboolean
. Default value: false
.
If this is true, this task will fail if any 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.
Use this task to run a Windows .bat or .cmd script. Optionally, allow it to permanently modify environment variables.
Note
This task is not compatible with Windows containers. If you need to run a batch script on a Windows container, use the command line task instead.
For information on supporting multiple platforms, see cross platform scripting.
ExamplesCreate test.bat
at the root of your repo:
@echo off
echo Hello World from %AGENT_NAME%.
echo My ID is %AGENT_ID%.
echo AGENT_WORKFOLDER contents:
@dir %AGENT_WORKFOLDER%
echo AGENT_BUILDDIRECTORY contents:
@dir %AGENT_BUILDDIRECTORY%
echo BUILD_SOURCESDIRECTORY contents:
@dir %BUILD_SOURCESDIRECTORY%
echo Over and out.
To run this script, add the following task to your pipeline.
- task: BatchScript@1
inputs:
filename: 'test.bat'
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: Cmd Capabilities This task does not satisfy any demands for subsequent tasks in the job. Command restrictions Any Settable variables Any Agent version 1.83.0 or greater 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