Reputation: 253
How to get folder name in a repository in azure pipeline using bash? We have repository named abcd, under that repo we have folder1, folder2, how do we get that folder name and print in echo using bash. and can we use this variable in release pipeline, is that possible??
Upvotes: 0
Views: 3622
Reputation: 40603
To get directories in a given folder you may use this:
- task: PowerShell@2
displayName: Get all directories of $(Build.SourcesDirectory) and assign to variable
inputs:
targetType: 'inline'
script: |
$arr = Get-ChildItem '$(Build.SourcesDirectory)' |
Where-Object {$_.PSIsContainer} |
Foreach-Object {$_.Name}
echo "##vso[task.setvariable variable=arr;]$arr"
- task: PowerShell@2
displayName: List all directories from variable
inputs:
targetType: 'inline'
script: |
echo '$(arr)'
Upvotes: 2