3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Bitrise APIを使ってみよう!

Posted at

やりたいこと

iOS/Androidのアプリを全てBitriseでCI/CDしているが、アプリケーションの数が30を超え管理するのが面倒になってきた。
この手のサービスはだいたいAPIがあるので、それを使って解決しちゃおうぜ!

Bitrise API

APIの概要については以下のページで確認できる。
https://devcenter.bitrise.io/jp/api/api-index/

で、APIの一覧はここにある。
https://api-docs.bitrise.io/

パッとみた感じだと、一通りの機能が揃っていて使い勝手良さそう。
ドキュメントがSwaggerで作られていることも、個人的にポイント高め!

認証

当然だけど認証しないとAPIは使用できない。
リクエストヘッダーのAuthorizationに、アクセストークンを設定すれば良い。

アクセストークンはアカウント設定画面のSecurityから作成できる。
スクリーンショット 2019-10-11 11.39.36.png

適当にアクセストークンの名前と期限を設定する。(画像では無期限にしている)
スクリーンショット 2019-10-11 11.40.10.png

こんな感じでアクセストークンが生成される。
アクセストークンは再表示ができないため、メモし忘れると作り直しになるので注意が必要!
スクリーンショット 2019-10-11 11.43.56.png

実際に使ってみる

使用する準備ができたので、実際に使ってみる。
一番オーソドックスなアプリケーションの一覧を取得するAPIを使用してみる。

インターフェースはこんな感じ。
スクリーンショット 2019-10-11 11.54.55.png

Base URLはhttps://api.bitrise.io/v0.1/と記載が上の方にあったので、https://api.bitrise.io/v0.1/appsにクエリパラメーターつけてGET送信すれば良さそう。

作成日順に取ってみたかったので、curlだとこんな感じ。

$ curl -X GET "https://api.bitrise.io/v0.1/apps?sort_by=created_at" -H "accept: application/json" -H "Authorization: {アクセストークン}"

Json形式でアプリの一覧を取得することができた!

{
	"data": [
		{
			"slug": "xxxx",
			"title": "バイトル iOS (開発)",
			"project_type": "ios",
			"provider": "custom",
			"repo_owner": "dip",
			"repo_url": "git@xxx",
			"repo_slug": "baitoru_app_ios",
			"is_disabled": false,
			"status": 1,
			"is_public": false,
			"owner": {
				"account_type": "organization",
				"name": "DIP",
				"slug": "xxxx"
			},
			"avatar_url": "https://concrete-userfiles-production.s3.us-west-2.amazonaws.com/repositories/xxxx/avatar/avatar.png"
		},
		{
			"slug": "xxxx",
			"title": "バイトル Android (開発)",
			"project_type": "android",
			"provider": "custom",
			"repo_owner": "dip",
			"repo_url": "git@xxx",
			"repo_slug": "baitoru_app_androidstudio",
			"is_disabled": false,
			"status": 1,
			"is_public": false,
			"owner": {
				"account_type": "organization",
				"name": "DIP",
				"slug": "xxxx"
			},
			"avatar_url": "https://concrete-userfiles-production.s3.us-west-2.amazonaws.com/repositories/xxxx/avatar/avatar.png"
		},

        {省略}

	],
	"paging": {
		"total_item_count": 33,
		"page_item_limit": 50
	}
}

ここまでやればあとはBitrise APIでやりたい放題できる!
Bitrise最高!

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?