How to create a build task for publishing a beta to HockeyApp in addition to tagging and pushing a beta release to your remote git repo using the gradle-git plugin.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath ‘org.ajoberstar:gradle-git:1.2.0’
classpath ‘de.felixschulze.gradle:gradle-hockeyapp-plugin:3.0.1’
}
}

apply plugin: ‘org.ajoberstar.grgit’
apply plugin: ‘de.felixschulze.gradle.hockeyapp’

android {

}

hockeyapp {

}

tasks.whenTaskAdded { task ->
if (task.name.equals(“uploadBetaToHockeyApp”)) {
tasks.releaseBeta.dependsOn task
}
}

task releaseBeta << {
// Ex: v1.2.3.45
def tagName = “v${android.defaultConfig.versionName}.${android.defaultConfig.versionCode}”
grgit.tag.add(name: tagName, message: “Beta release ${tagName}”)
grgit.push(refsOrSpecs: [tagName])
}

Leave a Reply

Your email address will not be published. Required fields are marked *