可以创建必需的检查/拉取请求状态吗?
Possible to create Required Check / Pull Request Status?
我已经尝试了上面的 API 并且检查/状态是可选的,因此它不会阻止用户完成拉取请求。如何使状态成为必需?
要在 PR 上添加屏蔽,您还需要添加 Status Policy。
Status policy
Using status alone, details from an external service can be provided
to users within the PR experience. Sometimes, sharing information
about a PR is all that is necessary, but in other cases PRs should be
blocked from merging until requirements are met. Like the in-box
policies, the Status policy provides a way for external services to
block PR completion until requirements are met. If the policy is
required, it must pass in order to complete the pull request. If the
policy is optional, it is informational only, and a status of
succeeded is not required in order to complete the pull request.
Status policies are configured just like other branch policies. When
adding a new status policy, the name and genre of the status policy
must be entered. If the status has been posted previously you can pick
it from the list; if it is a new policy you can type in the name of
the policy in the format genre/name.
作为 Matt 分享的文档,
Status policy - provides a mechanism to block pull request completion
until the pull request status indicates success.
如果你想让这个状态需要用于拉取请求,你需要将这个状态配置添加为状态策略。因为拉取请求所需的状态信息只能从状态策略读取。
在您 运行 此 api 成功后,管道状态信息已发布到拉取请求中。此时需要再执行一步,使这个状态变为required.
第一步:
使用下面api得到对应的状态id:
GET https://dev.azure.com/{org name}/{project}/_apis/policy/types?api-version=6.0
然后您将从响应正文中找到 Status id。将这个id粘贴到txt中,下一步需要用到。
第二步:
运行 下方 api 使您之前添加的状态成为必需:
POST https://dev.azure.com/{org name}/{repo name}/_apis/policy/Configurations?api-version=5.0
请求正文:
{
"type": {
"id": "{xxxx}" \Put the **Status id** you copied in above step
},
"isBlocking": true, \ IMPORTANT! Please set it to **true** since **false** means it is opitional
"isEnabled": true, \Enable this for pull request
"settings": {
"invalidateOnSourceUpdate": false,
"statusName": "APIStatus", \Specify the status name you used while you create a status
"statusGenre": "vsts-rm", \Same as above
"scope": [
{
"repositoryId": "2fe327b4-66f5-4ce3-9227-dfd2ec80af1c", \Specify this policy would apply to
"refName": "refs/heads/master",
"matchKind": "Exact"
}
]
}
}
我已经尝试了上面的 API 并且检查/状态是可选的,因此它不会阻止用户完成拉取请求。如何使状态成为必需?
要在 PR 上添加屏蔽,您还需要添加 Status Policy。
Status policy
Using status alone, details from an external service can be provided to users within the PR experience. Sometimes, sharing information about a PR is all that is necessary, but in other cases PRs should be blocked from merging until requirements are met. Like the in-box policies, the Status policy provides a way for external services to block PR completion until requirements are met. If the policy is required, it must pass in order to complete the pull request. If the policy is optional, it is informational only, and a status of succeeded is not required in order to complete the pull request.
Status policies are configured just like other branch policies. When adding a new status policy, the name and genre of the status policy must be entered. If the status has been posted previously you can pick it from the list; if it is a new policy you can type in the name of the policy in the format genre/name.
作为 Matt 分享的文档,
Status policy - provides a mechanism to block pull request completion until the pull request status indicates success.
如果你想让这个状态需要用于拉取请求,你需要将这个状态配置添加为状态策略。因为拉取请求所需的状态信息只能从状态策略读取。
在您 运行 此 api 成功后,管道状态信息已发布到拉取请求中。此时需要再执行一步,使这个状态变为required.
第一步:
使用下面api得到对应的状态id:
GET https://dev.azure.com/{org name}/{project}/_apis/policy/types?api-version=6.0
然后您将从响应正文中找到 Status id。将这个id粘贴到txt中,下一步需要用到。
第二步:
运行 下方 api 使您之前添加的状态成为必需:
POST https://dev.azure.com/{org name}/{repo name}/_apis/policy/Configurations?api-version=5.0
请求正文:
{
"type": {
"id": "{xxxx}" \Put the **Status id** you copied in above step
},
"isBlocking": true, \ IMPORTANT! Please set it to **true** since **false** means it is opitional
"isEnabled": true, \Enable this for pull request
"settings": {
"invalidateOnSourceUpdate": false,
"statusName": "APIStatus", \Specify the status name you used while you create a status
"statusGenre": "vsts-rm", \Same as above
"scope": [
{
"repositoryId": "2fe327b4-66f5-4ce3-9227-dfd2ec80af1c", \Specify this policy would apply to
"refName": "refs/heads/master",
"matchKind": "Exact"
}
]
}
}