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 3 years have passed since last update.

やりたいこと

Bitriseでざっくりと、「ビルド → AppCenter Release → Slack投稿」の順でWorkflowを組んでいる。
Slackの投稿メッセージはビルド終わったことしか伝えてないので、AppCenterのURLも貼り付けたい!

やり方

使用しているインテグレーションで、もしかしたら環境変数に設定してくれているかもしれない!
3rdパーティ製のものを使用しているが項目はなさそう...。(https://github.com/fileformat/bitrise-step-appcenter-app-release)
AppCenterAppRelease.png

しょうがないのでAppCenter CLIで解決しようと思ったが、latestを取るオプションはなかった。

$ appcenter distribute releases show -h

Shows full details about release

Usage: appcenter distribute releases show -r|--release-id <arg> [-a|--app <arg>]

Options:
    -r|--release-id <arg>             Release ID                                                                                            
    -a|--app <arg>                    Specify app in the <ownerName>/<appName> format                                                       

Common Options (works on all commands):
       --disable-telemetry             Disable telemetry for this command                                                                   
    -v|--version                       Display appcenter version                                                                            
       --quiet                         Auto-confirm any prompts without waiting for input                                                   
    -h|--help                          Display help for current command                                                                     
       --env <arg>                     Environment when using API token                                                                     
       --token <arg>                   API token                                                                                            
       --output <arg>                  Output format: json                                                                                  
       --debug                         Display extra output for debugging                     


$ appcenter distribute releases list -h

Shows the list of all releases for the application

Usage: appcenter distribute releases list [-a|--app <arg>]

Options:
    -a|--app <arg>             Specify app in the <ownerName>/<appName> format                                                              

Common Options (works on all commands):
       --disable-telemetry             Disable telemetry for this command                                                                   
    -v|--version                       Display appcenter version                                                                            
       --quiet                         Auto-confirm any prompts without waiting for input                                                   
    -h|--help                          Display help for current command                                                                     
       --env <arg>                     Environment when using API token                                                                     
       --token <arg>                   API token                                                                                            
       --output <arg>                  Output format: json                                                                                  
       --debug                         Display extra output for debugging                          

上記のlistでjson形式で出力すればなんとかなりそうだぞ!
(下のは整形した結果のやつ)

$ appcenter distribute releases list --app xxx/xxxxxx --token xxxxxxxxxx --output json
[
	{
		"id": 3,
		"version": "97",
		"origin": "appcenter",
		"shortVersion": "7.12.2",
		"enabled": true,
		"uploadedAt": "2019-08-09T05:45:01.000Z",
		"distributionGroups": [
			{
				"id": "00000000-0000-0000-0000-000000000000",
				"name": "Collaborators"
			}
		],
		"destinations": [
			{
				"name": "Collaborators",
				"id": "00000000-0000-0000-0000-000000000000",
				"destinationType": "group"
			}
		]
	},
	{
		"id": 2,
		"version": "97",
		"origin": "appcenter",
		"shortVersion": "7.12.2",
		"enabled": true,
		"uploadedAt": "2019-08-02T09:22:54.000Z",
		"distributionGroups": [
			{
				"id": "00000000-0000-0000-0000-000000000000",
				"name": "Collaborators"
			}
		],
		"destinations": [
			{
				"name": "Collaborators",
				"id": "00000000-0000-0000-0000-000000000000",
				"destinationType": "group"
			}
		]
	},
	{
		"id": 1,
		"version": "96",
		"origin": "appcenter",
		"shortVersion": "7.12.1",
		"enabled": true,
		"uploadedAt": "2019-07-19T07:40:59.000Z",
		"distributionGroups": [
			{
				"id": "00000000-0000-0000-0000-000000000000",
				"name": "Collaborators"
			}
		],
		"destinations": [
			{
				"name": "Collaborators",
				"id": "00000000-0000-0000-0000-000000000000",
				"destinationType": "group"
			}
		]
	},
	{
		"id": 27,
		"version": "19",
		"origin": "appcenter",
		"shortVersion": "7.17.0",
		"enabled": true,
		"uploadedAt": "2019-11-21T00:42:58.000Z",
		"distributionGroups": [
			{
				"id": "00000000-0000-0000-0000-000000000000",
				"name": "Collaborators"
			}
		],
		"destinations": [
			{
				"name": "Collaborators",
				"id": "00000000-0000-0000-0000-000000000000",
				"destinationType": "group"
			}
		]
	}
]

最終的にこんな感じで取ることにした。
取得したJsonに対してjqでパースして更新日時順にソートした結果をリバースしてIDを取り出す!

$ appcenter distribute releases list --app xxx/xxxxxx --token xxxxxxxxxx --output json | jq '. | sort_by(.uploadedAt) | reverse | .[0].id'

27

これをenvmanで環境変数に突っ込んだらうまくいきそう!
さらに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?