Last active
August 21, 2026 17:21
-
-
Save peteraritchie/1bfe03c43f2e7eb5917908c753528fae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| Gets the build validation policies for repositories associated with solution files in the specified path. | |
| .DESCRIPTION | |
| Retrieves and lists the build validation branch policies for repositories that correspond to solution files found in the specified path. | |
| .PARAMETER Path | |
| Specifies the path to search for solution files. | |
| #> | |
| [CmdletBinding()] | |
| param( | |
| [string]$Path = ".", | |
| [string]$BranchName = "main" | |
| ) | |
| foreach ($d in (Get-ChildItem -Path $Path -Filter .git -Recurse -Hidden -Directory)) | |
| { | |
| $gitRepoRoot = Split-Path $d.FullName; | |
| Write-Debug "Git repository root: $gitRepoRoot"; | |
| $potentialRepoName = Split-Path $gitRepoRoot -Leaf; | |
| Write-Debug "Potential ADO repository name: $potentialRepoName"; | |
| $repositoryId = az repos show --repository $potentialRepoName --query id -o tsv 2>$null; | |
| if ([string]::IsNullOrWhiteSpace($repositoryId)) { | |
| Write-Host "Repository not found: $gitRepoRoot"; | |
| } else {` | |
| Write-Debug "Repository ID: $repositoryId"; | |
| $policies = az repos policy list --repository-id $repositoryId --branch $BranchName | ConvertFrom-Json | Where-Object { $_.type.displayName -eq "Build" }; | |
| if($policies.Count -eq 0) { | |
| Write-Host "$potentialRepoName@$BranchName : No build policies"; | |
| } else { | |
| foreach ($policy in $policies) { | |
| Write-Debug "Processing policy: '$($policy.settings.displayName)'"; | |
| $buildDefinitionId = $policy.settings.buildDefinitionId; | |
| Write-Debug "Build Definition ID: $buildDefinitionId"; | |
| $pipelineFilename = az pipelines show --id $buildDefinitionId --query "process.yamlFilename" -o tsv; | |
| if([string]::IsNullOrWhiteSpace($policy.settings.displayName)) { | |
| $displayName = ""; | |
| } else { | |
| $displayName = "($($policy.settings.displayName))"; | |
| } | |
| "$potentialRepoName@$BranchName : $pipelineFilename $displayName"; | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment