Change current working directory in Azure Pipelines

Viewed 71127

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?

2 Answers

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

Related