LoginSignup
16
16

More than 5 years have passed since last update.

gradleからdeploygateへアップロードする

Posted at

deploygate

転記元: Yukiの枝折 - gradleからdeploygateへアップロードする

Get Started.

  1. Projectルート直下にあるbuild.gradleにclasspathを追加.
  2. Moduleのbuild.gradleにdeploygate taskを追加.
  3. deploygate taskのパラメタをカスタマイズ
  4. gradle uploadDeployGateでアップロード

Edit build.gradle

Projectルート直下にあるbuild.gradleにあるclasspathに下記を追加する.

dependencies {
    // ...
    classpath 'com.deploygate:gradle:0.6.2'
}

NOTE: Module直下のbuild.gradleではない

Module直下にあるbuild.gradleにdeploygate taskを追加する.
deploygate taskのテンプレートは下記.

apply plugin: 'deploygate'

deploygate {
  userName = "[owner name]"
  token = "[token]"

  apks {
    release {
      sourceFile = file("[apk1 file path]")
    }

    debug {
      sourceFile = file("[apk2 file path]")

      //Below is optional
      message = "test upload2 sample"
      visibility = "public" // default private
      distributionKey = "[distribution_key]"
      releaseNote = "release note sample"
    }
  }
}

各パラメータに指定する情報は下記サイトを参照.
https://deploygate.com/docs/api

Param Description
owner アプリの所有者名. Endpoint APIパスの一部で使用される.
token API Key.
sourceFile アップロードするアプリバイナリ.
message Push時に付与するメッセージ(optional)
visibility 新たにアップするアプリのプライバシー設定(optional)

deploygateのEndpoint api uriは次のフォーマットに従う.
https://deploygate.com/api/users/[owner name]/apps

owner nameは自身のdeploygateユーザページから確認できる.

tokenには発行されているAPI Keyを指定する. API keyはプロフィール設定から確認可能.

sourceFileにはアップロードするapkバイナリのパスを指定する.

messageには任意のメッセージを設定できる. このメッセージはテスタにも公開される.

visibilityアプリを新たにアップロードする際に指定できる公開設定. publicかprivate(default)を指定可能. この値は新しくアプリをアップロードする場合に参照され, アプリ更新時には無視される.

tokenを直接build.gradleに記載しないため, 環境変数やlocal.propertiesを読み込む方法をとるのが一般的である.
下記はlocal.propertiesに追加したプロパティdev.key.deploygateをtokenとするサンプル.

deploygate {
    // load local.propertis
    Properties properties = new Properties()
    properties.load(project.rootProject.file('local.properties').newDataInputStream())

    userName = "yuki312"
    token = properties.getProperty('dev.key.deploygate')

    apks {
        release {
            sourceFile = file("./build/outputs/apk/app-release.apk")
        }

        debug {
            sourceFile = file("./build/outputs/apk/app-debug.apk")

            //Below is optional
            message = "test message"
            visibility = "public" // default private
        }
    }
}

Reference

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