LoginSignup
1
0

More than 3 years have passed since last update.

目的

弊社のアプリはAppCenterでクラッシュログを収集しています。
アプリのCI/CD環境としてBitriseを使用していますが、Androidのmapping.txtをアップロードするインテグレーションがありません。

仕方がないのでAppCenter CLIであげてしまいましょう!

やり方

まずはAppCenter CLIのドキュメントを漁ってみます!(スタートして長くないサービスなので日本語対応は期待できません。)
https://docs.microsoft.com/ja-jp/appcenter/

クラッシュログのサービス名はDiagnosticsになるので、サイドバーを漁ってみるとそれっぽいのがありますね。
https://docs.microsoft.com/ja-jp/appcenter/diagnostics/android-deobfuscation

Appcenter CLIでできそうなのは分かったので、コマンドの詳細なオプションを調べてみましょう。
ぱっと見る感じだと、必要な情報は全て簡単に取得できそうですね。

$ appcenter crashes upload-mappings -h

Upload the Android mappings for the application

Usage: appcenter crashes upload-mappings [-c|--version-code <arg>] [-n|--version-name <arg>] [-m|--mapping <arg>] [-a|--app <arg>]

Options:
    -c|--version-code <arg>             The version code to associate with the mappings.                                                                                                                  
    -n|--version-name <arg>             The version name to associate with the mappings.                                                                                                                  
    -m|--mapping <arg>                  Path to an Android mapping.txt file.                                                                                                                              
    -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                  

ということで最終的にできたbashはこちらです!

VERSION_CODE=`grep "versionCode" ${APP_GRADLE_PATH} | sed -e 's/[^.0-9]//g'`
VERSION_NAME=`grep "versionName" ${APP_GRADLE_PATH} | sed -e 's/[^.0-9]//g'`

if hash appcenter 2>/dev/null; then
  echo "Microsoft AppCenter CLI already installed."
else
  echo "Microsoft AppCenter CLI is not installed. Installing..."
  npm install -g appcenter-cli
fi

appcenter crashes upload-mappings  \
--version-code ${VERSION_CODE}  \
--version-name ${VERSION_NAME}  \
--mapping ${BITRISE_MAPPING_PATH} \
--app ${APPCENTER_ORG}/${APPCENTER_NAME}  \
--token ${APPCENTER_API_TOKEN} \
--quiet

パラメータもこんな感じになっています。簡単ですね!

パラメーター名 説明
APP_GRADLE_PATH アプリのgradleのパス
VERSION_CODE アプリのバージョンコード
VERSION_NAME アプリのバージョン名
BITRISE_MAPPING_PATH mapping.txtのパス
APPCENTER_ORG AppCenterのURLに含まれる企業名
APPCENTER_NAME AppCenterのURLに含まれるアプリ名
APPCENTER_API_TOKEN AppCenter CLI/APIを叩くためのアクセストークン
1
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
1
0