Skip to content

Instantly share code, notes, and snippets.

@undownding
Created August 26, 2018 02:09
Show Gist options
  • Save undownding/0a7f135c512ca294f8f136c8147f49d4 to your computer and use it in GitHub Desktop.
Save undownding/0a7f135c512ca294f8f136c8147f49d4 to your computer and use it in GitHub Desktop.
applicationVariants.all { variant ->
if (variant.buildType.name == 'release') {
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk') && output.zipAlign) {
def fileName = "ezbuy_V${defaultConfig.versionName}_${new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))}_signature.apk"
output.outputFile = new File(outputFile.parent, fileName)
}
}
} else { // buildType -> debug
def buildNumber = System.getenv("BUILD_NUMBER")
def jenkinsBuild = buildNumber != null ? buildNumber : "0"
if (jenkinsBuild != '0') {
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk') && output.zipAlign) {
def fileName = "ezbuy-v${defaultConfig.versionName}-${variant.buildType.name}-jenkins-${jenkinsBuild}.apk"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment