I'm developing a CI for Python package in Azure Pipelines (https://github.com/scikit-image/scikit-image/blob/azure-pipelines/azure-pipelines.yml). At some point, I need to step out of the source code directory to allow pytest
to discover an installation of this package, and run the corresponding tests.
The issue I'm facing is related to the fact that cd
, cd C:
, etc commands do not seem to cause any effect, so that the current working directory remains unchanged (in this specific case, D:\a\1\s
).
Is there a way to overcome the described limitation?
It took many hours to find the solution, but, apparently, there is a way to specify working directory for specific script - https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/command-line?view=vsts&tabs=yaml :
- script: # script path or inline workingDirectory: # displayName: # failOnStderr: # env: # mapping of environment variables to add
Simple Solution to know the directory location in Azure devops :-
- task: CmdLine@2 inputs: script: | echo '$(System.DefaultWorkingDirectory)' dir dir subfoldername
where you need to invoke the command line and get the current path by using System.DefaultWorkingDirectory and dir will list you all the folders and files and using dir subfoldername we can traverse into subfolders
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With