此版本的 GitHub Enterprise 已停止服务 2022-06-03. 即使针对重大安全问题,也不会发布补丁。 要获得更好的性能、改进的安全性和新功能,请升级到 GitHub Enterprise 的最新版本。 如需升级方面的帮助,请联系 GitHub Enterprise 支持。
We've recently moved some of the REST API documentation. If you can't find what you're looking for, you might try the new Branches, Collaborators, Commits, Deploy Keys, Deployments, GitHub Pages, Releases, Metrics, Webhooks REST API pages.
部署状态
List deployment statuses
Users with pull access can view deployment statuses for a deployment:
参数
| � �头 |
|---|
| 名称, 类型, 描述 |
acceptstringSetting to |
| 路径参数 |
| 名称, 类型, 描述 |
ownerstring必选The account owner of the repository. The name is not case sensitive. |
repostring必选The name of the repository. The name is not case sensitive. |
deployment_idinteger必选deployment_id parameter |
| 查询参数 |
| 名称, 类型, 描述 |
per_pageintegerThe number of results per page (max 100). 默认值: |
pageintegerPage number of the results to fetch. 默认值: |
HTTP 响应状态代� �
| 状态代� � | 描述 |
|---|---|
200 | OK |
404 | Resource not found |
代� �示例
curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/deployments/DEPLOYMENT_ID/statusesResponse
Status: 200[
{
"url": "https://api.github.com/repos/octocat/example/deployments/42/statuses/1",
"id": 1,
"node_id": "MDE2OkRlcGxveW1lbnRTdGF0dXMx",
"state": "success",
"creator": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"description": "Deployment finished successfully.",
"environment": "production",
"target_url": "https://example.com/deployment/42/output",
"created_at": "2012-07-20T01:19:13Z",
"updated_at": "2012-07-20T01:19:13Z",
"deployment_url": "https://api.github.com/repos/octocat/example/deployments/42",
"repository_url": "https://api.github.com/repos/octocat/example",
"environment_url": "https://test-branch.lab.acme.com",
"log_url": "https://example.com/deployment/42/output"
}
]预览通知
New features in the Deployments API on GitHub are currently available during a public beta. Please see the blog post for full details.
To access the new environment parameter, the two new values for the state parameter (in_progress and queued), and use auto_inactive on production deployments during the public beta period, you must provide the following custom media type in the Accept header:
application/vnd.github.flash-preview+jsonThe inactive state and the log_url, environment_url, and auto_inactive parameters are currently available for developers to preview. Please see the blog post for full details.
To access the API during the preview period, you must provide a custom media type in the Accept header:
application/vnd.github.ant-man-preview+jsonCreate a deployment status
Users with push access can create deployment statuses for a given deployment.
GitHub Apps require read & write access to "Deployments" and read-only access to "Repo contents" (for private repos). OAuth Apps require the repo_deployment scope.
参数
| � �头 |
|---|
| 名称, 类型, 描述 |
acceptstringSetting to |
| 路径参数 |
| 名称, 类型, 描述 |
ownerstring必选The account owner of the repository. The name is not case sensitive. |
repostring必选The name of the repository. The name is not case sensitive. |
deployment_idinteger必选deployment_id parameter |
| 正文参数 |
| 名称, 类型, 描述 |
statestring必选The state of the status. Note: To use the 可以是以下其中之一: |
target_urlstringThe target URL to associate with this status. This URL should contain output to keep the user updated while the task is running or serve as historical information for what happened in the deployment. Note: It's recommended to use the 默认值: |
log_urlstringThe full URL of the deployment's output. This parameter replaces 默认值: |
descriptionstringA short description of the status. The maximum description length is 140 characters. 默认值: |
environmentstringName for the target deployment environment, which can be changed when setting a deploy status. For example, 可以是以下其中之一: |
environment_urlstringSets the URL for accessing your environment. Default: 默认值: |
auto_inactivebooleanAdds a new |
HTTP 响应状态代� �
| 状态代� � | 描述 |
|---|---|
201 | Created |
422 | Validation failed |
代� �示例
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/deployments/DEPLOYMENT_ID/statuses \
-d '{"environment":"production","state":"success","log_url":"https://example.com/deployment/42/output","description":"Deployment finished successfully."}'Response
Status: 201{
"url": "https://api.github.com/repos/octocat/example/deployments/42/statuses/1",
"id": 1,
"node_id": "MDE2OkRlcGxveW1lbnRTdGF0dXMx",
"state": "success",
"creator": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"description": "Deployment finished successfully.",
"environment": "production",
"target_url": "https://example.com/deployment/42/output",
"created_at": "2012-07-20T01:19:13Z",
"updated_at": "2012-07-20T01:19:13Z",
"deployment_url": "https://api.github.com/repos/octocat/example/deployments/42",
"repository_url": "https://api.github.com/repos/octocat/example",
"environment_url": "https://test-branch.lab.acme.com",
"log_url": "https://example.com/deployment/42/output"
}预览通知
New features in the Deployments API on GitHub are currently available during a public beta. Please see the blog post for full details.
To access the new environment parameter, the two new values for the state parameter (in_progress and queued), and use auto_inactive on production deployments during the public beta period, you must provide the following custom media type in the Accept header:
application/vnd.github.flash-preview+jsonThe inactive state and the log_url, environment_url, and auto_inactive parameters are currently available for developers to preview. Please see the blog post for full details.
To access the API during the preview period, you must provide a custom media type in the Accept header:
application/vnd.github.ant-man-preview+jsonGet a deployment status
Users with pull access can view a deployment status for a deployment:
参数
| � �头 |
|---|
| 名称, 类型, 描述 |
acceptstringSetting to |
| 路径参数 |
| 名称, 类型, 描述 |
ownerstring必选The account owner of the repository. The name is not case sensitive. |
repostring必选The name of the repository. The name is not case sensitive. |
deployment_idinteger必选deployment_id parameter |
status_idinteger必选 |
HTTP 响应状态代� �
| 状态代� � | 描述 |
|---|---|
200 | OK |
404 | Resource not found |
代� �示例
curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/deployments/DEPLOYMENT_ID/statuses/STATUS_IDResponse
Status: 200{
"url": "https://api.github.com/repos/octocat/example/deployments/42/statuses/1",
"id": 1,
"node_id": "MDE2OkRlcGxveW1lbnRTdGF0dXMx",
"state": "success",
"creator": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"description": "Deployment finished successfully.",
"environment": "production",
"target_url": "https://example.com/deployment/42/output",
"created_at": "2012-07-20T01:19:13Z",
"updated_at": "2012-07-20T01:19:13Z",
"deployment_url": "https://api.github.com/repos/octocat/example/deployments/42",
"repository_url": "https://api.github.com/repos/octocat/example",
"environment_url": "https://test-branch.lab.acme.com",
"log_url": "https://example.com/deployment/42/output"
}预览通知
New features in the Deployments API on GitHub are currently available during a public beta. Please see the blog post for full details.
To access the new environment parameter, the two new values for the state parameter (in_progress and queued), and use auto_inactive on production deployments during the public beta period, you must provide the following custom media type in the Accept header:
application/vnd.github.flash-preview+jsonThe inactive state and the log_url, environment_url, and auto_inactive parameters are currently available for developers to preview. Please see the blog post for full details.
To access the API during the preview period, you must provide a custom media type in the Accept header:
application/vnd.github.ant-man-preview+json