Azure DevOps - How to monitor the files & folders placed into the Build Pipeline Workfolder

%3CLINGO-SUB%20id%3D%22lingo-sub-2481508%22%20slang%3D%22en-US%22%3EAzure%20DevOps%20-%20How%20to%20monitor%20the%20files%20%26amp%3B%20folders%20placed%20into%20the%20Build%20Pipeline%20Workfolder%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2481508%22%20slang%3D%22en-US%22%3E%3CP%3EWhen%20we%20are%20building%20a%20new%20Pipeline%20into%20Azure%20DevOps%2C%20we%20don't%20have%20any%20visibility%20on%20the%20server%20itself%20and%20his%20content%20placed%20into%20work%20folder.%3C%2FP%3E%3CP%3EIn%20many%20situation%2C%20like%20debugging%2C%20that%20vision%20is%20really%20useful%20to%20find%20a%20file%20or%20a%20path%20to%20apply%20into%20another%20task%20(like%20Code%20Coverage%20report%20path).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20do%20that%2C%20the%20simplest%20option%20is%20to%20place%20into%20the%20pipeline%20flow%20one%20PowerShell%20step%20with%20this%20simple%20execution.%3C%2FP%3E%3CP%3EIn%20Yaml%20mode%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-yaml%22%3E%3CCODE%3E-%20powershell%3A%20%7C%0A%20%20%20Write-Host%20%22Show%20all%20folder%20content%22%0A%20%20%20Get-ChildItem%20-Path%20%24(Agent.WorkFolder)%5C*.*%20-Recurse%20-Force%0A%20%20errorActionPreference%3A%20continue%0A%20%20displayName%3A%20'PowerShell%20Script%20List%20folder%20structure'%0A%20%20continueOnError%3A%20true%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EIn%20visual%20editor%20mode%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22image_2021-06-24_184555.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F290984i98FCF8AB42976822%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image_2021-06-24_184555.png%22%20alt%3D%22image_2021-06-24_184555.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EAt%20the%20next%20execution%2C%20you%20will%20have%20into%20the%20Pipeline%20execution%20log%20all%20folders%20and%20files%20placed%20into%20the%20agent%20workplace%20like%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image_2021-06-24_184757.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F290986iAA9D50D7CA4C018F%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image_2021-06-24_184757.png%22%20alt%3D%22image_2021-06-24_184757.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EYou%20can%20use%20the%20search%20button%20or%20View%20raw%20log%20option%20to%20look%20the%20file%20or%20folder%20you%20are%20looking%20for.%3C%2FP%3E%3CP%3EThat%20task%20could%20be%20disable%20in%20standard%20usage%2C%20and%20enable%20only%20when%20you%20need%20to%20debug.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFabrice%20Romelard%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2481508%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EBuild%20pipelines%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDevOps%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Epipeline%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Regular Contributor

When we are building a new Pipeline into Azure DevOps, we don't have any visibility on the server itself and his content placed into work folder.

In many situation, like debugging, that vision is really useful to find a file or a path to apply into another task (like Code Coverage report path).

 

To do that, the simplest option is to place into the pipeline flow one PowerShell step with this simple execution.

In Yaml mode:

- powershell: |
   Write-Host "Show all folder content"
   Get-ChildItem -Path $(Agent.WorkFolder)\*.* -Recurse -Force
  errorActionPreference: continue
  displayName: 'PowerShell Script List folder structure'
  continueOnError: true

In visual editor mode:

image_2021-06-24_184555.png

At the next execution, you will have into the Pipeline execution log all folders and files placed into the agent workplace like:

image_2021-06-24_184757.png

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.

 

Fabrice Romelard

0 Replies