- https://github.com/takezoe/gitbucket/wiki/API-WebHook
- https://gist.github.com/tanacasino/8bbce76bf2c16aea2646
- gitbucket/gitbucket#41
GitBucketのAccount SettingsからPersonal access tokenを発行しておきます。
{
"message": "Not Found"
}
{
"message": "Requires authentication"
}
{
"message": "Bad credentials"
}
トークンを発行したユーザ情報
GET /api/v3/user
サンプルリクエスト
curl \
-H "Authorization: token {TOKEN}"
-H "Accept: application/json" \
"http://yourgitbucket.example.org/api/v3/user"
指定したユーザ情報
GET api/v3/users/:user
サンプルリクエスト
curl \
-H "Authorization: token {TOKEN}"
-H "Accept: application/json" \
"http://yourgitbucket.example.org/api/v3/users/shiena"
サンプルレスポンス
{
"login": "shiena",
"email": "shiena@example.org",
"type": "User",
"site_admin": false,
"created_at": "2015-07-05T14:38:29Z",
"url": "http://yourgitbucket.example.org/api/v3/users/shiena",
"html_url": "http://yourgitbucket.example.org/shiena"
}
GET /api/v3/rate_limit
サンプルリクエスト
curl \
-H "Authorization: token {TOKEN}"
-H "Accept: application/json" \
"http://yourgitbucket.example.org/api/v3/rate_limit"
サンプルレスポンス
{
"message": "Rate limiting is not enabled."
}
GET /api/v3/repos/:user/:repo
サンプルリクエスト
curl \
-H "Authorization: token {TOKEN}"
-H "Accept: application/json" \
"http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld"
サンプルレスポンス
{
"name": "helloworld",
"full_name": "shiena/helloworld",
"description": "",
"watchers": 0,
"forks": 0,
"private": true,
"default_branch": "master",
"owner": {
"login": "shiena",
"email": "shiena@example.org",
"type": "User",
"site_admin": false,
"created_at": "2015-07-05T14:38:29Z",
"url": "http://yourgitbucket.example.org/api/v3/users/shiena",
"html_url": "http://yourgitbucket.example.org/shiena"
},
"forks_count": 0,
"watchers_count": 0,
"url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld",
"http_url": "http://yourgitbucket.example.org/git/shiena/helloworld.git",
"clone_url": "http://yourgitbucket.example.org/git/shiena/helloworld.git",
"html_url": "http://yourgitbucket.example.org/shiena/helloworld"
}
POST /api/v3/repos/:user/:repo/statuses/:sha
パラメータ
Name | Type | Description |
---|---|---|
state | string | 必須。ステータスは pending / success / error / failure |
target_url | string | ステータスに関連するURL |
description | string | ステータスの短い説明 |
context | string | ステータスを変更したシステム名。省略すると default |
サンプルリクエスト
curl \
-X POST \
-H "Authorization: token {TOKEN}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"state":"success", "target_url":"https://example.org/build/status", "description":"The build succeeded", "context":"continuous-integration/jenkins"}' \
"http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/statuses/a0b546d2cbd34e5e952da280eb7addac3efd4d1d"
サンプルレスポンス
{
"created_at": "2015-07-12T17:34:54Z",
"updated_at": "2015-07-12T17:57:17Z",
"state": "success",
"target_url": "https://example.org/build/status",
"description": "The build succeeded",
"id": 1,
"context": "continuous-integration/jenkins",
"creator": {
"login": "shiena",
"email": "shiena@example.org",
"type": "User",
"site_admin": false,
"created_at": "2015-07-05T14:38:29Z",
"url": "http://yourgitbucket.example.org/api/v3/users/shiena",
"html_url": "http://yourgitbucket.example.org/shiena"
},
"url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/commits/a0b546d2cbd34e5e952da280eb7addac3efd4d1d/statuses"
}
GET /api/v3/repos/:user/:repo/commits/:ref/statuses
:ref
はハッシュ、ブランチ名、タグ名のいずれか
リクエストサンプル
curl \
-H "Authorization: token {TOKEN}"
-H "Accept: application/json" \
"http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/commits/a0b546d2cbd34e5e952da280eb7addac3efd4d1d/statuses"
サンプルレスポンス
[
{
"created_at": "2015-07-12T17:34:54Z",
"updated_at": "2015-07-12T17:37:15Z",
"state": "success",
"target_url": "https://example.org/build/status",
"description": "The build succeeded",
"id": 1,
"context": "continuous-integration/jenkins",
"creator": {
"login": "shiena",
"email": "shiena@example.org",
"type": "User",
"site_admin": false,
"created_at": "2015-07-05T14:38:29Z",
"url": "http://yourgitbucket.example.org/api/v3/users/shiena",
"html_url": "http://yourgitbucket.example.org/shiena"
},
"url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/commits/a0b546d2cbd34e5e952da280eb7addac3efd4d1d/statuses"
}
]
GET /api/v3/repos/:user/:repo/commits/:ref/status
リクエストサンプル
curl \
-H "Authorization: token {TOKEN}"
-H "Accept: application/json" \
"http://yourgitbucket.example.org/api/v3/repos/{USER_NAME}/{REPOSITORY_NAME}/commits/{REF}/status"
サンプルレスポンス
{
"state": "success",
"sha": "a0b546d2cbd34e5e952da280eb7addac3efd4d1d",
"total_count": 1,
"statuses": [
{
"created_at": "2015-07-12T17:34:54Z",
"updated_at": "2015-07-12T17:57:17Z",
"state": "success",
"target_url": "https://example.org/build/status",
"description": "The build succeeded",
"id": 1,
"context": "continuous-integration/jenkins",
"creator": {
"login": "shiena",
"email": "shiena@example.org",
"type": "User",
"site_admin": false,
"created_at": "2015-07-05T14:38:29Z",
"url": "http://yourgitbucket.example.org/api/v3/users/shiena",
"html_url": "http://yourgitbucket.example.org/shiena"
},
"url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/commits/a0b546d2cbd34e5e952da280eb7addac3efd4d1d/statuses"
}
],
"repository": {
"name": "helloworld",
"full_name": "shiena/helloworld",
"description": "",
"watchers": 0,
"forks": 0,
"private": true,
"default_branch": "master",
"owner": {
"login": "shiena",
"email": "shiena@example.org",
"type": "User",
"site_admin": false,
"created_at": "2015-07-05T14:38:29Z",
"url": "http://yourgitbucket.example.org/api/v3/users/shiena",
"html_url": "http://yourgitbucket.example.org/shiena"
},
"forks_count": 0,
"watchers_count": 0,
"url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld",
"http_url": "http://yourgitbucket.example.org/git/shiena/helloworld.git",
"clone_url": "http://yourgitbucket.example.org/git/shiena/helloworld.git",
"html_url": "http://yourgitbucket.example.org/shiena/helloworld"
},
"url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/commits/a0b546d2cbd34e5e952da280eb7addac3efd4d1d/status"
}
GET /api/v3/repos/:user/:repo/pulls
curl \
-H "Authorization: token {TOKEN}"
-H "Accept: application/json" \
"http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/pulls"
サンプルレスポンス
[
{
"number": 2,
"updated_at": "2015-07-12T15:36:06Z",
"created_at": "2015-07-12T15:36:06Z",
"head": {
"sha": "51a8582f89c40a148cdb559f8a9c519f6ec8589b",
"ref": "version",
"repo": {
"name": "helloworld",
"full_name": "shiena/helloworld",
"description": "",
"watchers": 0,
"forks": 0,
"private": true,
"default_branch": "master",
"owner": {
"login": "shiena",
"email": "shiena@example.org",
"type": "User",
"site_admin": false,
"created_at": "2015-07-05T14:38:29Z",
"url": "http://yourgitbucket.example.org/api/v3/users/shiena",
"html_url": "http://yourgitbucket.example.org/shiena"
},
"forks_count": 0,
"watchers_count": 0,
"url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld",
"http_url": "http://yourgitbucket.example.org/git/shiena/helloworld.git",
"clone_url": "http://yourgitbucket.example.org/git/shiena/helloworld.git",
"html_url": "http://yourgitbucket.example.org/shiena/helloworld"
},
"label": "version",
"user": {
"login": "shiena",
"email": "shiena@example.org",
"type": "User",
"site_admin": false,
"created_at": "2015-07-05T14:38:29Z",
"url": "http://yourgitbucket.example.org/api/v3/users/shiena",
"html_url": "http://yourgitbucket.example.org/shiena"
}
},
"base": {
"sha": "a0b546d2cbd34e5e952da280eb7addac3efd4d1d",
"ref": "master",
"repo": {
"name": "helloworld",
"full_name": "shiena/helloworld",
"description": "",
"watchers": 0,
"forks": 0,
"private": true,
"default_branch": "master",
"owner": {
"login": "shiena",
"email": "shiena@example.org",
"type": "User",
"site_admin": false,
"created_at": "2015-07-05T14:38:29Z",
"url": "http://yourgitbucket.example.org/api/v3/users/shiena",
"html_url": "http://yourgitbucket.example.org/shiena"
},
"forks_count": 0,
"watchers_count": 0,
"url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld",
"http_url": "http://yourgitbucket.example.org/git/shiena/helloworld.git",
"clone_url": "http://yourgitbucket.example.org/git/shiena/helloworld.git",
"html_url": "http://yourgitbucket.example.org/shiena/helloworld"
},
"label": "master",
"user": {
"login": "shiena",
"email": "shiena@example.org",
"type": "User",
"site_admin": false,
"created_at": "2015-07-05T14:38:29Z",
"url": "http://yourgitbucket.example.org/api/v3/users/shiena",
"html_url": "http://yourgitbucket.example.org/shiena"
}
},
"title": "バージョン追加",
"body": "追加",
"user": {
"login": "shiena",
"email": "shiena@example.org",
"type": "User",
"site_admin": false,
"created_at": "2015-07-05T14:38:29Z",
"url": "http://yourgitbucket.example.org/api/v3/users/shiena",
"html_url": "http://yourgitbucket.example.org/shiena"
},
"html_url": "http://yourgitbucket.example.org/shiena/helloworld/pull/2",
"url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/pulls/2",
"commits_url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/pulls/2/commits",
"review_comments_url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/pulls/2/comments",
"review_comment_url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/pulls/comments/{number}",
"comments_url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/issues/2/comments",
"statuses_url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/statuses/51a8582f89c40a148cdb559f8a9c519f6ec8589b"
}
]
GET /api/v3/repos/:user/:repo/pulls/:id
サンプルリクエスト
curl \
-H "Authorization: token {TOKEN}"
-H "Accept: application/json" \
"http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/pulls/2"
サンプルレスポンス
{
"number": 2,
"updated_at": "2015-07-12T15:36:06Z",
"created_at": "2015-07-12T15:36:06Z",
"head": {
"sha": "51a8582f89c40a148cdb559f8a9c519f6ec8589b",
"ref": "version",
"repo": {
"name": "helloworld",
"full_name": "shiena/helloworld",
"description": "",
"watchers": 0,
"forks": 0,
"private": true,
"default_branch": "master",
"owner": {
"login": "shiena",
"email": "shiena@example.org",
"type": "User",
"site_admin": false,
"created_at": "2015-07-05T14:38:29Z",
"url": "http://yourgitbucket.example.org/api/v3/users/shiena",
"html_url": "http://yourgitbucket.example.org/shiena"
},
"forks_count": 0,
"watchers_count": 0,
"url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld",
"http_url": "http://yourgitbucket.example.org/git/shiena/helloworld.git",
"clone_url": "http://yourgitbucket.example.org/git/shiena/helloworld.git",
"html_url": "http://yourgitbucket.example.org/shiena/helloworld"
},
"label": "version",
"user": {
"login": "shiena",
"email": "shiena@example.org",
"type": "User",
"site_admin": false,
"created_at": "2015-07-05T14:38:29Z",
"url": "http://yourgitbucket.example.org/api/v3/users/shiena",
"html_url": "http://yourgitbucket.example.org/shiena"
}
},
"base": {
"sha": "a0b546d2cbd34e5e952da280eb7addac3efd4d1d",
"ref": "master",
"repo": {
"name": "helloworld",
"full_name": "shiena/helloworld",
"description": "",
"watchers": 0,
"forks": 0,
"private": true,
"default_branch": "master",
"owner": {
"login": "shiena",
"email": "shiena@example.org",
"type": "User",
"site_admin": false,
"created_at": "2015-07-05T14:38:29Z",
"url": "http://yourgitbucket.example.org/api/v3/users/shiena",
"html_url": "http://yourgitbucket.example.org/shiena"
},
"forks_count": 0,
"watchers_count": 0,
"url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld",
"http_url": "http://yourgitbucket.example.org/git/shiena/helloworld.git",
"clone_url": "http://yourgitbucket.example.org/git/shiena/helloworld.git",
"html_url": "http://yourgitbucket.example.org/shiena/helloworld"
},
"label": "master",
"user": {
"login": "shiena",
"email": "shiena@example.org",
"type": "User",
"site_admin": false,
"created_at": "2015-07-05T14:38:29Z",
"url": "http://yourgitbucket.example.org/api/v3/users/shiena",
"html_url": "http://yourgitbucket.example.org/shiena"
}
},
"title": "バージョン追加",
"body": "追加",
"user": {
"login": "shiena",
"email": "shiena@example.org",
"type": "User",
"site_admin": false,
"created_at": "2015-07-05T14:38:29Z",
"url": "http://yourgitbucket.example.org/api/v3/users/shiena",
"html_url": "http://yourgitbucket.example.org/shiena"
},
"html_url": "http://yourgitbucket.example.org/shiena/helloworld/pull/2",
"url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/pulls/2",
"commits_url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/pulls/2/commits",
"review_comments_url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/pulls/2/comments",
"review_comment_url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/pulls/comments/{number}",
"comments_url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/issues/2/comments",
"statuses_url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/statuses/51a8582f89c40a148cdb559f8a9c519f6ec8589b"
}
GET /api/v3/repos/:user/:repo/pulls/:id/commits
サンプルリクエスト
curl \
-H "Authorization: token {TOKEN}"
-H "Accept: application/json" \
"http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/pulls/2/commits"
サンプルレスポンス
[
{
"sha": "51a8582f89c40a148cdb559f8a9c519f6ec8589b",
"commit": {
"message": "Add version\n",
"author": {
"name": "Mitsuhiro Koga",
"email": "shiena@example.org",
"date": "2015-07-12T15:34:52Z"
},
"committer": {
"name": "Mitsuhiro Koga",
"email": "shiena@example.org",
"date": "2015-07-12T15:34:52Z"
},
"url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/git/commits/51a8582f89c40a148cdb559f8a9c519f6ec8589b"
},
"parents": [
{
"sha": "a0b546d2cbd34e5e952da280eb7addac3efd4d1d",
"url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/commits/a0b546d2cbd34e5e952da280eb7addac3efd4d1d"
}
],
"url": "http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/commits/51a8582f89c40a148cdb559f8a9c519f6ec8589b"
}
]
GET /api/v3/repos/:user/:repo/issues/:id/comments
サンプルリクエスト
curl \
-H "Authorization: token {TOKEN}" \
-H "Accept: application/json" \
"http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/issues/1/comments"
サンプルレスポンス
[
{
"id": 1,
"user": {
"login": "shiena",
"email": "shiena@example.org",
"type": "User",
"site_admin": false,
"created_at": "2015-07-05T14:38:29Z",
"url": "http://yourgitbucket.example.org/api/v3/users/shiena",
"html_url": "http://yourgitbucket.example.org/shiena"
},
"body": "こめんと",
"created_at": "2015-07-12T15:31:10Z",
"updated_at": "2015-07-12T15:31:10Z",
"html_url": "http://yourgitbucket.example.org/shiena/helloworld/issues/1#comment-1"
}
]
POST /api/v3/repos/:user/:repo/issues/:id/comments
パラメータ
Name | Type | Description |
---|---|---|
body | string | コメント |
サンプルリクエスト
curl \
-X POST \
-H "Authorization: token {TOKEN}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"body":"Me too"}' \
"http://yourgitbucket.example.org/api/v3/repos/shiena/helloworld/issues/1/comments"
サンプルレスポンス
{
"id": 1,
"user": {
"login": "shiena",
"email": "shiena@example.org",
"type": "User",
"site_admin": false,
"created_at": "2015-07-05T14:38:29Z",
"url": "http://yourgitbucket.example.org/api/v3/users/shiena",
"html_url": "http://yourgitbucket.example.org/shiena"
},
"body": "Me too",
"created_at": "2015-07-12T18:04:02Z",
"updated_at": "2015-07-12T18:04:02Z",
"html_url": "http://yourgitbucket.example.org/shiena/helloworld/issues/1#comment-1"
}