am9417
am9417

Reputation: 1036

Pass arguments to Python task in Azure

I am running a script to which I want to add a parameter (here -u for unbuffered stdout). On local machine, I would just run python -u script.py.

Now, I want to run this Python script with unbuffered output on an Azure pipeline. Without unbuffered output, the task in my pipeline would be the following:

  - task: PythonScript@0

    displayName: 'Run script.py'
    inputs:
      scriptSource: filePath
      scriptPath: 'script.py'
      workingDirectory: 'myDir/'

How can I add the -u (or any other) argument to Python command? Is that possible with the "PythonScript" task at all?

I have tried to use arguments input, but that's obviously the arguments passed to my python script (e.g. after the "script.py" part). Also, tweaking somehow the pythonInterpreter input to "python.exe -u" to include the parameter, but the Python executable can't be found get recognised and the script won't run.

Upvotes: 0

Views: 1009

Answers (1)

Krzysztof Madej
Krzysztof Madej

Reputation: 40603

The easiest way actually would be call it like a bash script:

- bash: python -u myDir/script.py
  displayName: 'Run script.py'

Upvotes: 1

Related Questions