0

Is there a way to avoid executing a python script in the temp directory? I mean, even though I set the working directory to be the repository on which I want to execute my python script I cannot manage to tell Azure DevOps to run the script on my actual working directory, which is my repostory.$(Build.Repository.LocalPath).

All of this because I use a python script that is configured on my pipeline and that uses some modules from my repository, and when importing the modules, an ImportError: No module named my_module error ocurres.

Here's what I'm referring to.

C:\python27\python.exe C:\agent\my_agent\_work\_temp\ec6523f-efsd....py As you can see on the output from Azure DevOps, the script from my pipeline is executing on the _temp directory on which there are no modules to import and the error comes out.

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
Javier Ramirez
  • 337
  • 1
  • 2
  • 12

1 Answers1

0

i was using script step (not python script step) and it was working fine for me (and it was using imports:

steps:
- bash: python3 path/to/my/script_in_the_repo.py xxx yyy
4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • Thanks for your help, problem is that the script cannot be integrated in the repository, since it's code from other user. Anyways, I've managed to solve the issue by importing the modules with complete path by using ```imp``` module. – Javier Ramirez Mar 09 '20 at 07:02
  • 1
    i dont see it as an issue, you can always copy the script to the repo root, for instance. hardcoding the path wont work, since it can change anytime on the hosted agent – 4c74356b41 Mar 09 '20 at 07:03
  • btw, is it possible to set variables on build time to Azure DevOps from a python script? Like in TeamCity. – Javier Ramirez Mar 09 '20 at 07:03
  • you should start a new question, since this is a new question – 4c74356b41 Mar 09 '20 at 07:04