System hooks API

原文:https://docs.gitlab.com/ee/api/system_hooks.html

System hooks API

所有方法都需要管理员授权.

也可以使用Admin Area> System Hooks/admin/hooks )中的 UI 来配置系统挂钩的 URL 端点.

阅读有关系统挂钩的更多信息.

List system hooks

获取所有系统挂钩的列表.

  1. GET /hooks

请求示例:

  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/hooks"

响应示例:

  1. [ { "id":1, "url":"https://gitlab.example.com/hook", "created_at":"2016-10-31T12:32:15.192Z", "push_events":true, "tag_push_events":false, "merge_requests_events": true, "repository_update_events": true, "enable_ssl_verification":true } ]

Add new system hook

添加一个新的系统挂钩.

  1. POST /hooks
Attribute Type Required Description
url string yes 挂钩网址
token string no 用于验证收到的有效载荷的秘密令牌; 这将不会在响应中返回
push_events boolean no 设置为 true 时,挂钩将在推送事件时触发
tag_push_events boolean no 设置为 true 时,挂钩将在被推送的新标签上触发
merge_requests_events boolean no 触发合并请求事件的钩子
repository_update_events boolean no 触发挂钩存储库更新事件
enable_ssl_verification boolean no 触发挂钩时执行 SSL 验证

请求示例:

  1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/hooks?url=https://gitlab.example.com/hook"

响应示例:

  1. [ { "id":1, "url":"https://gitlab.example.com/hook", "created_at":"2016-10-31T12:32:15.192Z", "push_events":true, "tag_push_events":false, "merge_requests_events": true, "repository_update_events": true, "enable_ssl_verification":true } ]

Test system hook

  1. GET /hooks/:id
Attribute Type Required Description
id integer yes 钩子的 ID

请求示例:

  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/hooks/2"

响应示例:

  1. { "project_id" : 1, "owner_email" : "example@gitlabhq.com", "owner_name" : "Someone", "name" : "Ruby", "path" : "ruby", "event_name" : "project_create" }

Delete system hook

删除系统挂钩.

  1. DELETE /hooks/:id
Attribute Type Required Description
id integer yes 钩子的 ID

请求示例:

  1. curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/hooks/2"