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.
- Obtaining Files in a Branch Directory (Deprecated)
- Querying Branches of a Repository (Deprecated)
- Creating a Tag (Deprecated)
- Querying the Tag List of a Repository (Deprecated)
- Downloading a Repository
- Obtaining the Repository Branch List (Deprecated)
- Associating a Repository Group with a Member Group (Deprecated)
- Setting a Repository to Public or Private (Deprecated)
- Obtaining the List of Public Sample Templates (Deprecated)
- Adding a Deployment Key (Deprecated)
- Deleting a Repository Deployment Key (Deprecated)
- Querying a Repository in a Project (Deprecated)
- Obtaining the Number of Code Commits (Deprecated)
- Obtaining MR Details of a Repository
- Obtaining the Merge Request List (Deprecated)
- Creating a Protected Branch (Deprecated)
- Querying Details About a Repository (Deprecated)
- Obtaining the List of Public Sample Templates (Deprecated)
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.