Azure / azure-devops-cli-extension

Azure DevOps Extension for Azure CLI
https://docs.microsoft.com/en-us/cli/azure/ext/azure-devops/?view=azure-cli-latest
MIT License
633 stars 242 forks source link

[Feature Request] Add support for managing Status Check policies #1040

Open akitching opened 4 years ago

akitching commented 4 years ago

Is your feature request related to a problem? Please describe. There don't appear to be commands for creating and managing Status Check policies, even though policies created in the UI are reported when using az repos policy list.

Describe the solution you'd like Add a new status-check subgroup under policies with create and update commands to match the other policy types. az repos policy status-check create az repos policy status-check update

Additional context In case it helps anyone else, the Bash snippet below (using the wonderfully helpful invoke command) can be used in the meantime as a workaround to create status check policies.

echo '{
  "isBlocking": true,
  "isEnabled": true,
  "settings": {
    "authorId": null,
    "defaultDisplayName": null,
    "invalidateOnSourceUpdate": false,
    "policyApplicability": null,
    "scope": [
      {
        "matchKind": "Exact",
        "refName": "refs/heads/master",
        "repositoryId": "{REPOID}"
      }
    ],
    "statusGenre": null,
    "statusName": "{DESIREDSTATUS}"
  },
  "type": {
    "displayName": "Status",
    "id": "cbdc66da-9728-4af8-aada-9a5a32e4a226"
  }
}' > status-policy-request.json
az devops invoke --area policy \
    --resource configurations \
    --route-parameters project={PROJECTNAME} \
    --in-file status-policy-request.json \
    --http-method post \
    -o json
rm status-policy-request.json

https://docs.microsoft.com/en-us/rest/api/azure/devops/policy/configurations/create?view=azure-devops-rest-5.1

fcl-9 commented 1 year ago

Was looking to use the CLI to add a PR Status Check to support differential code coverage unfortunately it does not seem to be possible. The only possible way to achieve this is by using the Az DevOps API as previously stated by @akitching