我正在尝试禁用并再次启用为使用 Azure DevOps REST API 的分支创建的分支策略。
使用CURL
我能够获取已在存储库中创建的分支策略列表。
curl --url "https://dev.azure.com/{ORG}/{PROJ}/_apis/policy/configurations?api-version=6.0" --user "username:password" --request GET --header "Accept: application/json"
输出:
{
"count":1,
"value":[
{
"createdBy":{
"displayName":"Akshay B",
"url":"XXXX",
"_links":{
"avatar":{
"href":"XXXX"
}
},
"id":"XXXX-XXXX-XXXX-XXXX-e0fdec2c1636",
"uniqueName":"[email protected]",
"imageUrl":"XXXX",
"descriptor":"XXXX"
},
"createdDate":"2021-08-30T12:24:43.0238821Z",
"isEnabled":true,
"isBlocking":true,
"isDeleted":false,
"settings":{
"minimumApproverCount":2,
"creatorVoteCounts":false,
"allowDownvotes":false,
"resetOnSourcePush":false,
"requireVoteOnLastIteration":false,
"resetRejectionsOnSourcePush":false,
"blockLastPusherVote":false,
"scope":[
{
"refName":"refs/heads/master",
"matchKind":"Exact",
"repositoryId":"XXXX-XXXX-XXXX-XXXX-cd2a5c3167b3"
}
]
},
"isEnterpriseManaged":false,
"_links":{
"self":{
"href":"XXXX"
},
"policyType":{
"href":"XXXX"
}
},
"revision":1,
"id":2,
"url":"XXXX",
"type":{
"id":"XXXX-XXXX-XXXX-XXXX-4906e5d171dd",
"url":"XXXX",
"displayName":"Minimum number of reviewers"
}
}
]
}
现在我正在尝试使用以下CURL
命令禁用上面创建的策略:
curl --url "https://dev.azure.com/{ORG}/{PROJ}/_apis/policy/configurations/2?api-version=6.0" --user "username:password" --request PUT --header "Content-Type: application/json" --data '{\"isEnabled\":false}'
但我最终得到了错误:
{"$id":"1","innerException":null,"message":"TF400898: An Internal Error Occurred. Activity Id: xxxx-xxxx-xxxx-xxxx-70e5364888b7.","typeName":"Newtonsoft.Json.JsonReaderException, Newtonsoft.Json","typeKey":"JsonReaderException","errorCode":0,"eventId":0}
我在为该PUT
方法传递的 JSON 数据中遗漏了什么吗?
有许多分支策略(评论、构建等),每个策略的行为都不同。
对于审阅者政策,您可以使用DELETE
API:
https://dev.azure.com/{org}/{project}/_apis/policy/Configurations/{policy-id}?api-version=6.0
在curl
该--request
应DELETE
。
您可以policy-id
使用GET
您所做的api获取。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句