这个文档对我很有用:
https://github.com/MicrosoftDocs/azure-devops-docs/blob/master/docs/integrate/previous-apis/security/acls.md
API 适合我,使用 TFS 2017 更新 2,API 版本 3.2。
POST https://mytfsserver/mycollection/_apis/accesscontrollists/c788c23e-1b46-4162-8f5e-d7585343b5de
与身体:
{
"value": [
{
"inheritPermissions": true,
"token": "<your team project GUID>/406",
"acesDictionary": {
"Microsoft.TeamFoundation.Identity;S-1-9-1551374245-1217126478-2421225543-2840439466-2364649907-1-111749626-101504790-2465118485-2523779884": {
"descriptor": "Microsoft.TeamFoundation.Identity;S-1-9-1551374245-1217126478-2421225543-2840439466-2364649907-1-111749626-101504790-2465118485-2523779884",
"allow": 2071
}
}
}
]
}
对于环境,您必须将令牌更改为:
"你的团队项目 GUID/406/Environment/624"
406 是发布 id,624 是环境 id
这个查询对于列出 ReleaseManagement 中的所有条目很有用:
https://mytfsserver/mycollection/_apis/accesscontrollists/c788c23e-1b46-4162-8f5e-d7585343b5de
使用发布和环境定义的安全权限,看看响应中会发生什么。
注意:c788c23e-1b46-4162-8f5e-d7585343b5de = 发布管理的命名空间 ID
为了使用 API 创建发布定义,我必须使用预览版 API,因此 api-version 设置为 3.2-preview。