Adding a Webhook to a Specified Repository
Function
This API is used to add a webhook for a specified repository.
URI
POST /v1/repositories/{group_name}/{repository_name}/hooks
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
group_name |
Yes |
String |
Repository group name (the segment between the domain name and repository name in a clone address. Example: Demo00228 in git@repo.alpha.devcloud.intest.com:Demo00228/testword.git). |
repository_name |
Yes |
String |
Repository name. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
hook_url |
Yes |
String |
Trigger URL. |
service |
Yes |
String |
Event source. |
token |
No |
String |
Security token. |
hook_events |
Yes |
Array of strings |
Trigger events. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
error |
Error object |
Response error. |
result |
RepoHook object |
Response result. |
status |
String |
Response status. |
Parameter |
Type |
Description |
---|---|---|
build_events |
Boolean |
Whether to trigger build_events. |
created_at |
String |
Repository statistics creation time. |
enable_ssl_verification |
Boolean |
Whether to use SSL authentication. |
id |
Integer |
Hook ID. |
issues_events |
Boolean |
Whether to trigger issues_events. |
merge_requests_events |
Boolean |
Whether to trigger merge_requests_events. |
note_events |
Boolean |
Whether to trigger note_events. |
pipeline_events |
Boolean |
Whether to trigger pipeline_events. |
project_id |
Integer |
Repository ID. |
push_events |
Boolean |
Whether to trigger push_events. |
repository_update_events |
Boolean |
Whether to trigger repository_update_events. |
tag_push_events |
Boolean |
Whether to trigger tag_push_events. |
wiki_page_events |
Boolean |
Whether to trigger wiki_page_events. |
Example Requests
POST https://{endpoint}/v1/repositories/{group_name}/{repository_name}/hooks
{
"service" : 11,
"token" : "test",
"hook_url" : "https://alpha.devcloud.intest.com/",
"hook_events" : [ "push_events" ]
}
Example Responses
Status code: 200
OK
{
"result" : {
"id" : 5609,
"project_id" : 453489,
"created_at" : "2019-10-23 17:29:56",
"enable_ssl_verification" : false,
"push_events" : true,
"tag_push_events" : false,
"repository_update_events" : false,
"merge_requests_events" : false,
"issues_events" : false,
"note_events" : false,
"pipeline_events" : false,
"wiki_page_events" : false,
"build_events" : null
},
"status" : "success"
}
Status Codes
Status Code |
Description |
---|---|
200 |
OK |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.