system_hooks.md 6.84 KB
Newer Older
Marin Jankovski's avatar
Marin Jankovski committed
1 2
# System hooks

3
Your GitLab instance can perform HTTP POST requests on the following events: `project_create`, `project_destroy`, `project_rename`, `project_transfer`, `user_add_to_team`, `user_remove_from_team`, `user_create`, `user_destroy`, `key_create`, `key_destroy`, `group_create`, `group_destroy`, `user_add_to_group` and `user_remove_from_group`.
4 5 6

System hooks can be used, e.g. for logging or changing information in a LDAP server.

7
## Hooks request example
8

9 10 11 12 13 14
**Request header**:

```
X-Gitlab-Event: System Hook
```

15 16 17 18 19
**Project created:**

```json
{
          "created_at": "2012-07-21T07:30:54Z",
20
          "updated_at": "2012-07-21T07:38:22Z",
21 22
          "event_name": "project_create",
                "name": "StoreCloud",
Kei's avatar
Kei committed
23 24
         "owner_email": "johnsmith@gmail.com",
          "owner_name": "John Smith",
25 26
                "path": "storecloud",
 "path_with_namespace": "jsmith/storecloud",
27
          "project_id": 74,
28
  "project_visibility": "private",
29 30 31 32 33 34 35 36
}
```

**Project destroyed:**

```json
{
          "created_at": "2012-07-21T07:30:58Z",
37
          "updated_at": "2012-07-21T07:38:22Z",
38 39
          "event_name": "project_destroy",
                "name": "Underscore",
Kei's avatar
Kei committed
40
         "owner_email": "johnsmith@gmail.com",
41 42 43 44
          "owner_name": "John Smith",
                "path": "underscore",
 "path_with_namespace": "jsmith/underscore",
          "project_id": 73,
45
  "project_visibility": "internal",
46 47 48
}
```

49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
**Project renamed:**

```json
{
               "created_at": "2012-07-21T07:30:58Z",
               "updated_at": "2012-07-21T07:38:22Z",
               "event_name": "project_rename",
                     "name": "Underscore",
                     "path": "underscore",
      "path_with_namespace": "jsmith/underscore",
               "project_id": 73,
               "owner_name": "John Smith",
              "owner_email": "johnsmith@gmail.com",
       "project_visibility": "internal",
  "old_path_with_namespace": "jsmith/overscore",
}
```

**Project transferred:**

```json
{
               "created_at": "2012-07-21T07:30:58Z",
               "updated_at": "2012-07-21T07:38:22Z",
               "event_name": "project_transfer",
                     "name": "Underscore",
                     "path": "underscore",
      "path_with_namespace": "scores/underscore",
               "project_id": 73,
               "owner_name": "John Smith",
              "owner_email": "johnsmith@gmail.com",
       "project_visibility": "internal",
  "old_path_with_namespace": "jsmith/overscore",
}
```

85 86
**New Team Member:**

Kei's avatar
Kei committed
87
```json
88
{
89
                  "created_at": "2012-07-21T07:30:56Z",
90
                  "updated_at": "2012-07-21T07:38:22Z",
91 92 93 94 95 96 97 98
                  "event_name": "user_add_to_team",
              "project_access": "Master",
                  "project_id": 74,
                "project_name": "StoreCloud",
                "project_path": "storecloud",
 "project_path_with_namespace": "jsmith/storecloud",
                  "user_email": "johnsmith@gmail.com",
                   "user_name": "John Smith",
99
               "user_username": "johnsmith",
100 101
                     "user_id": 41,
          "project_visibility": "private",
102 103 104 105 106 107 108
}
```

**Team Member Removed:**

```json
{
109
                  "created_at": "2012-07-21T07:30:56Z",
110
                  "updated_at": "2012-07-21T07:38:22Z",
111 112 113 114 115 116 117 118
                  "event_name": "user_remove_from_team",
              "project_access": "Master",
                  "project_id": 74,
                "project_name": "StoreCloud",
                "project_path": "storecloud",
 "project_path_with_namespace": "jsmith/storecloud",
                  "user_email": "johnsmith@gmail.com",
                   "user_name": "John Smith",
119
               "user_username": "johnsmith",
120 121
                     "user_id": 41,
          "project_visibility": "private",
122 123 124 125 126 127
}
```

**User created:**

```json
128
{
129
   "created_at": "2012-07-21T07:44:07Z",
130
   "updated_at": "2012-07-21T07:38:22Z",
131 132
        "email": "js@gitlabhq.com",
   "event_name": "user_create",
133
         "name": "John Smith",
134
     "username": "js",
135
      "user_id": 41
136 137 138 139 140 141
}
```

**User removed:**

```json
142
{
143
   "created_at": "2012-07-21T07:44:07Z",
144
   "updated_at": "2012-07-21T07:38:22Z",
145 146 147
        "email": "js@gitlabhq.com",
   "event_name": "user_destroy",
         "name": "John Smith",
148
     "username": "js",
149
      "user_id": 41
150 151
}
```
152 153 154 155 156 157 158

**Key added**

```json
{
    "event_name": "key_create",
    "created_at": "2014-08-18 18:45:16 UTC",
159
    "updated_at": "2012-07-21T07:38:22Z",
160 161 162 163 164 165 166 167 168 169 170 171
      "username": "root",
           "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC58FwqHUbebw2SdT7SP4FxZ0w+lAO/erhy2ylhlcW/tZ3GY3mBu9VeeiSGoGz8hCx80Zrz+aQv28xfFfKlC8XQFpCWwsnWnQqO2Lv9bS8V1fIHgMxOHIt5Vs+9CAWGCCvUOAurjsUDoE2ALIXLDMKnJxcxD13XjWdK54j6ZXDB4syLF0C2PnAQSVY9X7MfCYwtuFmhQhKaBussAXpaVMRHltie3UYSBUUuZaB3J4cg/7TxlmxcNd+ppPRIpSZAB0NI6aOnqoBCpimscO/VpQRJMVLr3XiSYeT6HBiDXWHnIVPfQc03OGcaFqOit6p8lYKMaP/iUQLm+pgpZqrXZ9vB john@localhost",
           "id": 4
}
```

**Key removed**

```json
{
    "event_name": "key_destroy",
    "created_at": "2014-08-18 18:45:16 UTC",
172
    "updated_at": "2012-07-21T07:38:22Z",
173 174 175 176 177
      "username": "root",
           "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC58FwqHUbebw2SdT7SP4FxZ0w+lAO/erhy2ylhlcW/tZ3GY3mBu9VeeiSGoGz8hCx80Zrz+aQv28xfFfKlC8XQFpCWwsnWnQqO2Lv9bS8V1fIHgMxOHIt5Vs+9CAWGCCvUOAurjsUDoE2ALIXLDMKnJxcxD13XjWdK54j6ZXDB4syLF0C2PnAQSVY9X7MfCYwtuFmhQhKaBussAXpaVMRHltie3UYSBUUuZaB3J4cg/7TxlmxcNd+ppPRIpSZAB0NI6aOnqoBCpimscO/VpQRJMVLr3XiSYeT6HBiDXWHnIVPfQc03OGcaFqOit6p8lYKMaP/iUQLm+pgpZqrXZ9vB john@localhost",
            "id": 4
}
```
178 179 180 181 182 183

**Group created:**

```json
{
   "created_at": "2012-07-21T07:30:54Z",
184
   "updated_at": "2012-07-21T07:38:22Z",
185
   "event_name": "group_create",
186
         "name": "StoreCloud",
187 188
  "owner_email": "johnsmith@gmail.com",
   "owner_name": "John Smith",
189
         "path": "storecloud",
190 191 192 193 194 195 196 197 198
     "group_id": 78
}
```

**Group removed:**

```json
{
   "created_at": "2012-07-21T07:30:54Z",
199
   "updated_at": "2012-07-21T07:38:22Z",
200 201 202 203 204 205 206 207 208 209 210 211 212 213
   "event_name": "group_destroy",
         "name": "StoreCloud",
  "owner_email": "johnsmith@gmail.com",
   "owner_name": "John Smith",
         "path": "storecloud",
     "group_id": 78
}
```

**New Group Member:**

```json
{
    "created_at": "2012-07-21T07:30:56Z",
214
    "updated_at": "2012-07-21T07:38:22Z",
215 216 217 218 219 220 221
    "event_name": "user_add_to_group",
  "group_access": "Master",
      "group_id": 78,
    "group_name": "StoreCloud",
    "group_path": "storecloud",
    "user_email": "johnsmith@gmail.com",
     "user_name": "John Smith",
222
 "user_username": "johnsmith",
223 224 225 226 227 228 229 230
       "user_id": 41
}
```
**Group Member Removed:**

```json
{
    "created_at": "2012-07-21T07:30:56Z",
231
    "updated_at": "2012-07-21T07:38:22Z",
232 233 234 235 236 237 238
    "event_name": "user_remove_from_group",
  "group_access": "Master",
      "group_id": 78,
    "group_name": "StoreCloud",
    "group_path": "storecloud",
    "user_email": "johnsmith@gmail.com",
     "user_name": "John Smith",
239
 "user_username": "johnsmith",
240 241 242
       "user_id": 41
}
```