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
scriptSource
Type
(Required) Target script type: File path or Inline
scriptPath
Script Path
(Required when scriptSource == filePath) Path of the script to execute. Must be a fully qualified path or relative to $(System.DefaultWorkingDirectory).
script
Script
(Required when scriptSource == inline) The Python script to run
arguments
Arguments
(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.
pythonInterpreter
Python 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.
workingDirectory
Working directory
(Optional)
failOnStderr
Fail on standard error
(Optional) If true, this task will fail if any text is written to stderr.
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.