1

I have a Python script I am testing in Azure pipelines that works fine if I edit the yaml file to be:
- script: python Directory/test_script.py
I would like to run it using the PythonScript task because I need to pass arguments into the script and that doesn't seem to be supported using just the - script method.
My yaml file contains:

  inputs:
    scriptSource: 'filePath' 
    scriptPath: python Directory/test_script.py 
    arguments: --hello world

When the pipeline executes it shows the following error:
##[error]ENOENT: no such file or directory, stat '/home/vsts/work/1/s/python
How can I get the script to execute correctly so I can input parameters? I've also tried changing the workingDirectory parameter.

1 Answer 1

4

If you want to run python script you can use for instance Python Script task:

steps:
- task: PythonScript@0
  inputs:
    scriptSource: 'filePath' # Options: filePath, inline
    scriptPath: $(Build.SourcesDirectory)/stackoverflow/45/script.py # Required when scriptSource == filePath
    #script: # Required when scriptSource == inline
    #arguments: # Optional
    #pythonInterpreter: # Optional
    #workingDirectory: # Optional
    #failOnStderr: false # Optional
- bash: python $(Build.SourcesDirectory)/stackoverflow/45/script.py
- script: python $(Build.SourcesDirectory)/stackoverflow/45/script.py

Your mistake is putting python here scriptPath: python Directory/test_script.py. This should have only path to script but you also put here python, so agent tries to find folder python.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.