Adding a Hook to a Specified Repository
Function
Submit code to automatically trigger compilation and building and add a repository hook.
URI
POST /v1/repositories/{group_name}/{repository_name}/hooks
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
group_name |
Yes |
String |
Group Name (Example: git@repo.alpha.devcloud.inhuawei.com:Demo00228/testword.git Group Name: Demo00228) |
repository_name |
Yes |
String |
Repository name |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
Specifies the user token. It can be obtained by calling an IAM API. 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 |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
error |
Error object |
Response error. |
result |
RepoHook object |
Result |
status |
String |
Status code in a response |
Parameter |
Type |
Description |
---|---|---|
build_events |
Boolean |
Indicates whether to trigger the build_events event. |
created_at |
String |
Time when warehouse statistics are created. |
enable_ssl_verification |
Boolean |
Indicates whether to use SSL authentication. |
id |
Integer |
hook id |
issues_events |
Boolean |
Trigger issues_events |
merge_requests_events |
Boolean |
Whether to trigger the merge_requests_events event |
note_events |
Boolean |
Indicates whether to trigger the note_events event. |
pipeline_events |
Boolean |
Whether to trigger the pipeline_events event |
project_id |
Integer |
Specifies the repository ID. |
push_events |
Boolean |
Whether to trigger the push_events event |
repository_update_events |
Boolean |
Whether to trigger the repository_update_events event |
tag_push_events |
Boolean |
Whether to trigger the tag_push_events event |
wiki_page_events |
Boolean |
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.inhuawei.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.