Last active
July 4, 2018 13:07
-
-
Save yasiralijaved/b0e6b9424c440ce7c3efb2ef924e3968 to your computer and use it in GitHub Desktop.
app level build.gradle file to create Gradle's custom tasks "inernalQADist" and "externalQADist" that Jenkins calls to build and distribute the apk and also send the notification to a Slack Channel for Internal and External QA Teams
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gradle Plugin to publish APK to Google PlayStore right from the Gradle Task. | |
// https://github.com/Triple-T/gradle-play-publisher | |
apply plugin: 'com.github.triplet.play' | |
// Fabric.io Plugin | |
apply plugin: 'io.fabric' | |
// Slack Plugin For Gradle. https://github.com/Mindera/gradle-slack-plugin | |
apply plugin: 'com.mindera.gradle.slack' | |
def major = "2" | |
def minor = "0" | |
def change = "1" | |
def version = "${major}.${minor}.${change}" | |
// Get always-incremented number after every commit to be used as Version Code | |
static def gitCommitCount(){ | |
return "git rev-list HEAD --count".execute().text.trim().toInteger() | |
} | |
android { | |
minSdkVersion 18 | |
targetSdkVersion 27 | |
defaultConfig { | |
versionCode gitCommitCount() | |
versionName "${version}" | |
} | |
signingConfigs { | |
debug { | |
storeFile file("../keystore/myapp.keystore") | |
storePassword "pass" | |
keyAlias "alias" | |
keyPassword "pass" | |
} | |
internalQA { | |
storeFile file("../keystore/myapp.keystore") | |
storePassword "pass" | |
keyAlias "alias" | |
keyPassword "pass" | |
} | |
externalQA { | |
storeFile file("../keystore/myapp.keystore") | |
storePassword "pass" | |
keyAlias "alias" | |
keyPassword "pass" | |
} | |
release { | |
storeFile file("../keystore/myapp.keystore") | |
storePassword "pass" | |
keyAlias "alias" | |
keyPassword "pass" | |
} | |
} | |
buildTypes { | |
debug { | |
debuggable true | |
resValue("string", "app_name", "debug.MyApp") | |
applicationIdSuffix '.debug' | |
signingConfig signingConfigs.debug | |
} | |
internalQA { | |
debuggable false | |
minifyEnabled true | |
zipAlignEnabled true | |
shrinkResources true | |
resValue("string", "app_name", "internal.MyApp") | |
applicationIdSuffix '.internal' | |
signingConfig signingConfigs.internalQA | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
// Set Fabric Beta Tester Group | |
ext.betaDistributionGroupAliases="internal-qa-android" | |
} | |
externalQA { | |
debuggable false | |
minifyEnabled true | |
zipAlignEnabled true | |
shrinkResources true | |
resValue("string", "app_name", "external.MyApp") | |
applicationIdSuffix '.external' | |
signingConfig signingConfigs.externalQA | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
// Set Fabric Beta Tester Group | |
ext.betaDistributionGroupAliases="external-qa-android" | |
} | |
release { | |
debuggable false | |
minifyEnabled true | |
zipAlignEnabled true | |
shrinkResources true | |
signingConfig signingConfigs.release | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
} | |
} | |
} | |
// Used by Jenkins to distribute apk among Internal Testers via Fabric Beta | |
task internalQADist (type: GradleBuild) { | |
group 'MyApp Distribution' | |
description 'Task for Jenkins to distribute Build for Internal QA' | |
tasks = ['clean', | |
'cleanBuildCache', | |
'assembleInternalQA', | |
'crashlyticsUploadDistributionInternalQA'] | |
} | |
// Used by Jenkins to distribute apk among External Testers via Fabric Beta | |
task externalQADist (type: GradleBuild) { | |
group 'MyApp Distribution' | |
description 'Task for Jenkins to distribute Build for External QA' | |
tasks = ['clean', | |
'cleanBuildCache', | |
'assembleExternalQA', | |
'crashlyticsUploadDistributionExternalQA'] | |
} | |
// Slack Plugin For Gradle. https://github.com/Mindera/gradle-slack-plugin | |
slack { | |
url 'https://hooks.slack.com/services/abc/abc/abc' | |
dependsOnTasks 'crashlyticsUploadDistributionInternalQA', | |
'crashlyticsUploadDistributionExternalQA' | |
title "*```New Build Available | ${version} (${gitCommitCount()})] ```*https://fabric.io/url/to/myapp" | |
enabled = true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment