azure-devops-cli-extension icon indicating copy to clipboard operation
azure-devops-cli-extension copied to clipboard

[Feature Request] Add support for managing Status Check policies

Open akitching opened this issue 5 years ago • 1 comments

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

akitching avatar Aug 12 '20 17:08 akitching

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

fcl-9 avatar Sep 18 '23 11:09 fcl-9