問題点
gradle-deploygate-pluginを使うと、コマンド一発でDeployGateにアップ出来て非常に便利。
しかし、DeployGateにapkをアップした時に、あれ、これmasterでビルドしたっけか?master最新にしてたっけか?という不安に駆られる事があると思う。
解決方法
コマンド実行する時にmessageにブランチ名、ハッシュ値を含めるようにする。以下のような感じ、そしてちょっと一工夫して、releaseビルドのときには[production]
という文字が入るようにしている。
deploygate {
userName = "XXXX"
apks {
def branch = 'git rev-parse --abbrev-ref HEAD'.execute([], project.rootDir).in.text.trim()
def hash = 'git rev-parse --short HEAD'.execute([], project.rootDir).in.text.trim()
def commonMessage = System.getenv('MESSAGE') + " ${branch} ${hash}"
debug {
message = commonMessage
}
release {
message = "[production]" + commonMessage
}
}
}
これで以下のように実行すると、
MESSAGE="ほげほげ" ./gradlew uploadDeployGateDebug
DeployGateのメッセージのところには、
ほげほげ master 1856bca
という感じに入ってくれる。地味に便利。