How to copy all policies from one branch to another on Azure Devops with Az Cli

I need to automate the creation of a new branch from another and copy all the policies from the source branch. This will happen inside a YAML pipeline in ADO and Im implementing it via az cli.

At the moment Im stuck at this point, I was able to retrieve the policy list from a specified repo and branch:

REPOID=$(az repos list --query "[?name == '<nameOfRepo>'].id" --output tsv)  
POLICIES=$(az repos policy list --branch develop --repository-id $REPOID)

But from this point I can’t find from the documentation command list a command that helps me do that, because only specific policies creation are supported (create build policy, create reviewer policy…).

I found this article, but it explains only the creation of build policies.

Leave a Comment