Skip to content

Instantly share code, notes, and snippets.

@kazoo0217
Last active January 4, 2017 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazoo0217/71e2621eb02b60466ed8c4ad2bf859dd to your computer and use it in GitHub Desktop.
Save kazoo0217/71e2621eb02b60466ed8c4ad2bf859dd to your computer and use it in GitHub Desktop.
Bitbucket Cloud API

Bitbucket Cloud の API を使ってみた

Use the Bitbucket Cloud REST APIs: https://confluence.atlassian.com/bitbucket/use-the-bitbucket-cloud-rest-apis-222724129.html

$ curl https://api.bitbucket.org/2.0/repositories/{accountname}

OAuth on Bitbucket Cloud: https://confluence.atlassian.com/bitbucket/oauth-on-bitbucket-cloud-238027431.html

API 2.0 はトークンが取得できなくて挫折したので、App passwords を設定し API 1.0 で curl を使っていろいろやってみた。

App passwords を設定することでプライベートリポジトリにアクセスできる。

App passwords are here in Bitbucket Cloud: https://blog.bitbucket.org/2016/06/06/app-passwords-bitbucket-cloud/

以下の値はそれぞれ置き換えること

{accountname}:アカウント名
{repo_slug}:レポジトリ名
{app_password}:App passwords のパスワード

userの情報をjsonで取得

GET a user profile: https://confluence.atlassian.com/bitbucket/user-endpoint-296092264.html#userEndpoint-GETauserprofile

$ curl --user {accountname}:{app_password} https://api.bitbucket.org/1.0/user/

issueの情報をjsonで取得

GET a list of issues in a repository's tracker: https://confluence.atlassian.com/bitbucket/issues-resource-296095191.html#issuesResource-GETalistofissuesinarepository'stracker

$ curl --user {accountname}:{app_password} https://api.bitbucket.org/1.0/repositories/{accountname}/{repo_slug}/issues

issueを作成する

POST a new issue: https://confluence.atlassian.com/bitbucket/issues-resource-296095191.html#issuesResource-POSTanewissue

$ curl --user {accountname}:{app_password} https://api.bitbucket.org/1.0/repositories/{accountname}/{repo_slug}/issues --data "title=タイトルを入力&content=内容を入力&priority=優先度を入力&kind=タイプを入力&responsible=担当者を入力"

今日はここまで...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment