Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change current working directory in Azure Pipelines

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?

like image 389
soupault Avatar asked Dec 19 '18 18:12

soupault


2 Answers

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 
like image 191
soupault Avatar answered Oct 23 '22 07:10

soupault


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

like image 27
Shivam Tyagi Avatar answered Oct 23 '22 08:10

Shivam Tyagi