BatchScript@1 - Batch script v1 task
Use this task to run a Windows .bat
or .cmd
script. Optionally, the .bat
or .cmd
script can permanently modify environment variables.
filename
- Path
string
. 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
- Arguments
string
.
The arguments passed to the .cmd
or .bat
script.
modifyEnvironment
- Modify Environment
boolean
. Default value: False
.
Determines whether environment variable modifications will affect subsequent tasks.
workingFolder
- Working folder
string
.
The current working directory when a script is run. This defaults to the folder where the script is located.
failOnStandardError
- Fail on Standard Error
boolean
. 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.
None.
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.
Create 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'
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 |