Python Script task
Azure Pipelines
Use this task to run a Python script.
YAML snippet
# Python script
# Run a Python file or inline script
- task: PythonScript@0
inputs:
#scriptSource: 'filePath' # Options: filePath, inline
#scriptPath: # Required when scriptSource == filePath
#script: # Required when scriptSource == inline
#arguments: # Optional
#pythonInterpreter: # Optional
#workingDirectory: # Optional
#failOnStderr: false # Optional
Arguments
| Argument | Description |
|---|---|
scriptSourceType |
(Required) Target script type: File path or Inline |
scriptPathScript Path |
(Required when scriptSource == filePath) Path of the script to execute. Must be a fully qualified path or relative to $(System.DefaultWorkingDirectory). |
scriptScript |
(Required when scriptSource == inline) The Python script to run |
argumentsArguments |
(Optional) A string containing arguments passed to the script. They'll be available through sys.argv as if you passed them on the command line. |
pythonInterpreterPython interpreter |
(Optional) Absolute path to the Python interpreter to use. If not specified, the task assumes a Python interpreter is available on the PATH and simply attempts to run the python command. |
workingDirectoryWorking directory |
(Optional) |
failOnStderrFail on standard error |
(Optional) If true, this task will fail if any text is written to stderr. |
Task control options
Remarks
By default, this task will invoke python from the system path.
Run Use Python Version to put the version you want in the system path.
Open source
This task is open source on GitHub. Feedback and contributions are welcome.