Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Pipelines - Is there a way to view the folder structure?

I'm struggling to picture the folder structure of azure pipelines. I know there are some implicit directories like:

  • $(System.DefaultWorkingDirectory)
  • $(Build.ArtifactStagingDirectory)

Which are both folders on a specific build agent available from the pool.

Is there a way to view the folder structure and get a better understanding how things are laid out?

like image 353
Cristian E. Avatar asked Jul 27 '20 14:07

Cristian E.


People also ask

What is build SourcesDirectory?

Build.SourcesDirectory. The local path on the agent where your source code files are downloaded. For example: c:\agent_work\1\s. By default, new build pipelines update only the changed files.

What is DefaultWorkingDirectory?

System.DefaultWorkingDirectory. The directory to which artifacts are downloaded during deployment of a release. The directory is cleared before every deployment if it requires artifacts to be downloaded to the agent.

How do I view files in Azure Devops?

You can use the search button or View raw log option to look the file or folder you are looking for. That task could be disable in standard usage, and enable only when you need to debug.

How do I view Azure Devops pipeline?

To view active release pipelines, select Pipelines > Releases. From there, you can drill into the details of a release. For example, here we show the Release-3 pipeline.


5 Answers

You can use CMD task to call tree command in Microsoft-Hosted windows agent to get the folder structure.

My script:

echo "Structure of work folder of this pipeline:"
tree $(Agent.WorkFolder)\1 /f

echo "Build.ArtifactStagingDirectory:" 

echo "$(Build.ArtifactStagingDirectory)"

echo "Build.BinariesDirectory:" 

echo "$(Build.BinariesDirectory)"

echo "Build.SourcesDirectory:"

echo "$(Build.SourcesDirectory)"

The result:

enter image description here

$(Agent.WorkFolder) represents the working folder for current agent, $(Agent.WorkFolder)\1 represents the working folder for current pipeline.(Normally the first pipeline will be put in $(Agent.WorkFolder)\1, and the second $(Agent.WorkFolder)\2...)

So it's obvious that for one pipeline run, it has four folders by default: a(artifact folder), b(binaries folder), s(source folder) and TestResults(Test results folder). The s folder is where the source code files are downloaded. For build pipeline: $(Build.SourcesDirectory),$(Build.Repository.LocalPath) and $(System.DefaultWorkingDirectory) represent the same folder. More details see predefined variables.

like image 78
LoLance Avatar answered Oct 12 '22 22:10

LoLance


Another option is to add this to a YAML pipeline:

-powershell: Get-ChildItem -Path 'Insert root path' -recurse

It will look something like:

Get-ChildItem -Path C:\Test\*.txt -Recurse -Force

Directory: C:\Test\Logs\Adirectory

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        2/12/2019     16:16             20 Afile4.txt
-a-h--        2/12/2019     15:52             22 hiddenfile.txt
-a----        2/13/2019     13:26             20 LogFile4.txt

    Directory: C:\Test\Logs\Backup

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        2/12/2019     16:16             20 ATextFile.txt
-a----        2/12/2019     15:50             20 LogFile3.txt

    Directory: C:\Test\Logs

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        2/12/2019     16:16             20 Afile.txt
-a-h--        2/12/2019     15:52             22 hiddenfile.txt
-a----        2/13/2019     13:26             20 LogFile1.txt

    Directory: C:\Test

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        2/13/2019     08:55             26 anotherfile.txt
-a----        2/12/2019     15:40         118014 Command.txt
-a-h--        2/12/2019     15:52             22 hiddenfile.txt
-ar---        2/12/2019     14:31             27 ReadOnlyFile.txt

Here is documentation on the Get-ChildItem command if you need more information

like image 43
DreadedFrost Avatar answered Oct 12 '22 23:10

DreadedFrost


The documentation gives you examples of the folder structure. If that's not enough, add a PowerShell step that runs gci -rec -directory | select-object fullname or similar.

like image 39
Daniel Mann Avatar answered Oct 13 '22 00:10

Daniel Mann


enter image description here

source: user comment from this blog

Note that your full path may look different based on your environment.

For example: your Build.StagingDirectory path could be c:\agent_work\1\a OR
/home/vsts/work/1/a/

This is based on Agent.BuildDirectory or Pipeline.Workspace variable.(c:\agent_work\1 or /home/vsts/work/1 or /a/1 or something similar)

more in azure docs

like image 5
ns94 Avatar answered Oct 13 '22 00:10

ns94


It looks more like this(work directory of an Agent):

enter image description here

like image 1
Vidhya Sagar Reddy Avatar answered Oct 12 '22 22:10

Vidhya Sagar Reddy