0

In an Azure git pipeline script (.yml), I can set up a Python task like this

- task: PythonScript@0
  displayName: "Run scripts"
  inputs:
    scriptSource: 'filePath'
    scriptPath: 'myscript.py'
    arguments: '$a $b $c'

But it doesn't print output until the task is complete. Normally I would call python -u myscript.py but there isn't an option to pass parameters to python itself; they can only be passed to the script. How can I set the input as unbuffered?

twasbrillig
  • 17,084
  • 9
  • 43
  • 67
  • This has nothing to do with Git itself; it's specific to the Azure setup. However, they (Microsoft) copied a lot of this from others, and/or vice versa, so other pipeline setups use similar syntax in their YAML scripts. – torek Feb 23 '21 at 00:14

1 Answers1

0

Adding this to the Azure .yml script makes the output unbuffered, so that print statements appear right away:

variables:
- name: PYTHONUNBUFFERED
  value: PYTHONUNBUFFERED

It's an environment variable, and adding it here sets the value.

twasbrillig
  • 17,084
  • 9
  • 43
  • 67