azure-devops-cli-extension
azure-devops-cli-extension copied to clipboard
repository policy listing by id not working
Describe the bug
The argument --repository-id for az repos policy does not work as expected.
Command Name
az repos policy list Extension Name: azure-devops. Version: 0.17.0.
Errors: No policy is listed although there are policies applied to that repositry
To Reproduce:
The two commands below should produce the same output, but only the seconds produces response
az repos policy list --project ${project} -o table --repository-id ${id}
az repos policy list --project ${project} -o table | grep ${id}
Expected Behavior
List the policies for the supplied repository id
Environment Summary
Linux-5.4.0-42-generic-x86_64-with-glibc2.29
Python 3.8.2
Shell: bash
azure-cli 2.0.81 *
Extensions:
azure-devops 0.17.0
Reproduced with the following versions :
azure-cli 2.27.2
core 2.27.2
telemetry 1.0.6
Extensions:
azure-devops 0.20.0
Python (Linux) 3.6.10 (default, Aug 23 2021, 03:36:00)
I know it's kinda old, but I came across it only now
Try to add --branch flag to the command
It worked in my case
Ex: az repos policy list --repository-id <repo_id> --branch <branch_name>
Adding the --branch flag does workaround this issue, but this should still be considered a bug as you can't list all policies for the repository, regardless of the branch. If the --branch flag is required, then this is not documented in the help for the command. The --branch flag also does not appear to accept a wildcard value.
As a workaround you can filter with jq, but this is not ideal.
az repos policy list | jq '.[] | select(.settings.scope[0].repositoryId == "<REPO_UUID>")'