azure-devopsazure-pipelinesazure-pipelines-yaml

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:

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?


Solution

  • 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.