LoginSignup
4
4

More than 5 years have passed since last update.

gradle-deploygate-pluginでアップする時に自動的にブランチ名とハッシュ値をメッセージに入れる

Posted at

問題点

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

という感じに入ってくれる。地味に便利。

4
4
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
4
4