2019-05-10 15:33:54 +00:00
|
|
|
nix = load 'ci/nix.groovy'
|
2019-02-05 09:35:14 +00:00
|
|
|
utils = load 'ci/utils.groovy'
|
2018-08-21 15:17:25 +00:00
|
|
|
|
2019-04-11 11:29:37 +00:00
|
|
|
def bundle() {
|
2019-09-13 17:16:13 +00:00
|
|
|
/* we use the method because parameter build type does not take e2e into account */
|
2019-04-11 11:29:37 +00:00
|
|
|
def btype = utils.getBuildType()
|
2018-11-27 10:15:33 +00:00
|
|
|
/* Disable Gradle Daemon https://stackoverflow.com/questions/38710327/jenkins-builds-fail-using-the-gradle-daemon */
|
2019-06-04 16:50:29 +00:00
|
|
|
def gradleOpt = "-PbuildUrl='${currentBuild.absoluteUrl}' --console plain "
|
2020-01-23 13:34:21 +00:00
|
|
|
/* Can't take more digits than unsigned int */
|
|
|
|
def buildNumber = utils.readBuildNumber().substring(0, 10)
|
2019-05-31 18:39:53 +00:00
|
|
|
/* we don't need x86 for any builds except e2e */
|
2019-09-13 17:16:13 +00:00
|
|
|
env.ANDROID_ABI_INCLUDE="armeabi-v7a;arm64-v8a"
|
|
|
|
env.ANDROID_ABI_SPLIT="false"
|
2019-02-11 21:24:36 +00:00
|
|
|
|
2019-09-13 17:16:13 +00:00
|
|
|
/* some builds tyes require different architectures */
|
2019-05-31 18:39:53 +00:00
|
|
|
switch (btype) {
|
|
|
|
case 'e2e':
|
2019-09-13 17:16:13 +00:00
|
|
|
env.ANDROID_ABI_INCLUDE="x86" /* e2e builds are used with simulators */
|
2019-10-01 09:51:48 +00:00
|
|
|
break
|
2019-05-31 18:39:53 +00:00
|
|
|
case 'release':
|
2019-09-13 17:16:13 +00:00
|
|
|
env.ANDROID_ABI_SPLIT="true"
|
2019-06-14 15:06:38 +00:00
|
|
|
gradleOpt += "-PreleaseVersion='${utils.getVersion()}'"
|
2019-10-01 09:51:48 +00:00
|
|
|
break
|
2018-08-21 15:17:25 +00:00
|
|
|
}
|
2019-05-31 18:39:53 +00:00
|
|
|
|
2019-09-13 17:16:13 +00:00
|
|
|
/* credentials necessary to open the keystore and sign the APK */
|
2019-08-26 16:56:55 +00:00
|
|
|
withCredentials([
|
|
|
|
string(
|
|
|
|
credentialsId: 'android-keystore-pass',
|
|
|
|
variable: 'STATUS_RELEASE_STORE_PASSWORD'
|
|
|
|
),
|
|
|
|
usernamePassword(
|
|
|
|
credentialsId: 'android-keystore-key-pass',
|
|
|
|
usernameVariable: 'STATUS_RELEASE_KEY_ALIAS',
|
|
|
|
passwordVariable: 'STATUS_RELEASE_KEY_PASSWORD'
|
|
|
|
)
|
|
|
|
]) {
|
2019-09-13 17:16:13 +00:00
|
|
|
/* Nix target which produces the final APKs */
|
2019-08-26 16:56:55 +00:00
|
|
|
nix.build(
|
2019-09-13 17:16:13 +00:00
|
|
|
attr: 'targets.mobile.android.release',
|
2020-01-13 14:28:40 +00:00
|
|
|
conf: [
|
|
|
|
'status-im.ci': '1',
|
|
|
|
'status-im.build-type': btype,
|
|
|
|
'status-im.status-react.gradle-opts': gradleOpt,
|
2020-01-23 13:34:21 +00:00
|
|
|
'status-im.status-react.build-number': buildNumber,
|
2019-08-26 16:56:55 +00:00
|
|
|
],
|
|
|
|
safeEnv: [
|
|
|
|
'STATUS_RELEASE_KEY_ALIAS',
|
|
|
|
'STATUS_RELEASE_STORE_PASSWORD',
|
2019-09-13 17:16:13 +00:00
|
|
|
'STATUS_RELEASE_KEY_PASSWORD',
|
2019-08-26 16:56:55 +00:00
|
|
|
],
|
2020-02-25 21:42:47 +00:00
|
|
|
keepEnv: [
|
2019-09-13 17:16:13 +00:00
|
|
|
'ANDROID_ABI_SPLIT',
|
|
|
|
'ANDROID_ABI_INCLUDE',
|
|
|
|
'STATUS_RELEASE_STORE_FILE',
|
2019-08-26 16:56:55 +00:00
|
|
|
],
|
2020-02-25 21:42:47 +00:00
|
|
|
sandboxPaths: [
|
2019-09-13 17:16:13 +00:00
|
|
|
env.STATUS_RELEASE_STORE_FILE,
|
2019-08-26 16:56:55 +00:00
|
|
|
],
|
|
|
|
link: false
|
|
|
|
)
|
2018-08-21 15:17:25 +00:00
|
|
|
}
|
2019-02-11 21:24:36 +00:00
|
|
|
/* necessary for Fastlane */
|
2019-09-13 17:16:13 +00:00
|
|
|
def apks = renameAPKs()
|
|
|
|
/* for use with Fastlane */
|
|
|
|
env.APK_PATHS = apks.join(";")
|
|
|
|
return apks
|
|
|
|
}
|
|
|
|
|
|
|
|
def extractArchFromAPK(name) {
|
|
|
|
def pattern = /app-(.+)-[^-]+.apk/
|
|
|
|
/* extract architecture from filename */
|
|
|
|
def matches = (name =~ pattern)
|
|
|
|
if (matches.size() > 0) {
|
|
|
|
return matches[0][1]
|
|
|
|
}
|
2020-01-13 12:15:33 +00:00
|
|
|
if (utils.isE2EBuild()) {
|
2019-10-01 09:51:48 +00:00
|
|
|
return 'x86'
|
|
|
|
}
|
2019-09-13 17:16:13 +00:00
|
|
|
/* non-release builds make universal APKs */
|
|
|
|
return 'universal'
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* We need more informative filenames for all builds.
|
|
|
|
* For more details on the format see utils.pkgFilename().
|
|
|
|
**/
|
|
|
|
def renameAPKs() {
|
|
|
|
/* find all APK files */
|
|
|
|
def apkGlob = 'result/*.apk'
|
|
|
|
def found = findFiles(glob: apkGlob)
|
|
|
|
if (found.size() == 0) {
|
2019-10-01 09:51:48 +00:00
|
|
|
throw "APKs not found via glob: ${apkGlob}"
|
2019-09-13 17:16:13 +00:00
|
|
|
}
|
|
|
|
def renamed = []
|
|
|
|
/* rename each for upload & archiving */
|
|
|
|
for (apk in found) {
|
|
|
|
def arch = extractArchFromAPK(apk)
|
2019-11-20 12:42:41 +00:00
|
|
|
def pkg = utils.pkgFilename(env.BUILD_TYPE, 'apk', arch)
|
2019-09-13 17:16:13 +00:00
|
|
|
def newApk = "result/${pkg}"
|
|
|
|
renamed += newApk
|
|
|
|
sh "cp ${apk.path} ${newApk}"
|
|
|
|
}
|
|
|
|
return renamed
|
2018-08-21 15:17:25 +00:00
|
|
|
}
|
|
|
|
|
2018-09-21 11:57:06 +00:00
|
|
|
def uploadToPlayStore(type = 'nightly') {
|
2018-08-21 15:17:25 +00:00
|
|
|
withCredentials([
|
|
|
|
string(credentialsId: "SUPPLY_JSON_KEY_DATA", variable: 'GOOGLE_PLAY_JSON_KEY'),
|
|
|
|
]) {
|
2019-05-10 15:33:54 +00:00
|
|
|
nix.shell(
|
|
|
|
"fastlane android ${type}",
|
2020-02-25 21:42:47 +00:00
|
|
|
keepEnv: ['FASTLANE_DISABLE_COLORS', 'APK_PATHS', 'GOOGLE_PLAY_JSON_KEY'],
|
2020-01-17 15:45:03 +00:00
|
|
|
attr: 'shells.fastlane',
|
|
|
|
pure: false
|
2019-05-10 15:33:54 +00:00
|
|
|
)
|
2018-08-21 15:17:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def uploadToSauceLabs() {
|
2019-02-05 09:35:14 +00:00
|
|
|
def changeId = utils.changeId()
|
2018-08-30 10:46:37 +00:00
|
|
|
if (changeId != null) {
|
2018-11-19 17:37:04 +00:00
|
|
|
env.SAUCE_LABS_NAME = "${changeId}.apk"
|
2018-08-30 10:46:37 +00:00
|
|
|
} else {
|
2019-11-20 12:42:41 +00:00
|
|
|
def pkg = utils.pkgFilename(env.BUILD_TYPE, 'apk', 'x86')
|
2019-01-15 14:53:05 +00:00
|
|
|
env.SAUCE_LABS_NAME = "${pkg}"
|
2018-08-30 10:46:37 +00:00
|
|
|
}
|
2018-08-21 15:17:25 +00:00
|
|
|
withCredentials([
|
2019-07-01 15:39:16 +00:00
|
|
|
usernamePassword(
|
|
|
|
credentialsId: 'sauce-labs-api',
|
|
|
|
usernameVariable: 'SAUCE_USERNAME',
|
|
|
|
passwordVariable: 'SAUCE_ACCESS_KEY'
|
|
|
|
),
|
2018-08-21 15:17:25 +00:00
|
|
|
]) {
|
2019-05-10 15:33:54 +00:00
|
|
|
nix.shell(
|
|
|
|
'fastlane android saucelabs',
|
2020-02-25 21:42:47 +00:00
|
|
|
keepEnv: [
|
2019-09-13 17:16:13 +00:00
|
|
|
'FASTLANE_DISABLE_COLORS', 'APK_PATHS',
|
2019-05-10 15:33:54 +00:00
|
|
|
'SAUCE_ACCESS_KEY', 'SAUCE_USERNAME', 'SAUCE_LABS_NAME'
|
2019-11-20 12:42:41 +00:00
|
|
|
],
|
2019-11-29 10:20:08 +00:00
|
|
|
attr: 'shells.fastlane',
|
2019-11-20 12:42:41 +00:00
|
|
|
pure: false
|
2019-05-10 15:33:54 +00:00
|
|
|
)
|
2018-08-21 15:17:25 +00:00
|
|
|
}
|
2018-11-19 17:37:04 +00:00
|
|
|
return env.SAUCE_LABS_NAME
|
2018-08-21 15:17:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def uploadToDiawi() {
|
|
|
|
withCredentials([
|
2018-08-27 15:32:54 +00:00
|
|
|
string(credentialsId: 'diawi-token', variable: 'DIAWI_TOKEN'),
|
2018-08-21 15:17:25 +00:00
|
|
|
]) {
|
2019-05-10 15:33:54 +00:00
|
|
|
nix.shell(
|
|
|
|
'fastlane android upload_diawi',
|
2020-02-25 21:42:47 +00:00
|
|
|
keepEnv: ['FASTLANE_DISABLE_COLORS', 'APK_PATHS', 'DIAWI_TOKEN'],
|
2019-11-29 10:20:08 +00:00
|
|
|
attr: 'shells.fastlane',
|
2019-11-27 10:23:07 +00:00
|
|
|
pure: false
|
2019-05-10 15:33:54 +00:00
|
|
|
)
|
2018-08-21 15:17:25 +00:00
|
|
|
}
|
2018-08-27 15:32:54 +00:00
|
|
|
diawiUrl = readFile "${env.WORKSPACE}/fastlane/diawi.out"
|
|
|
|
return diawiUrl
|
2018-08-21 15:17:25 +00:00
|
|
|
}
|
|
|
|
|
2019-07-03 19:00:51 +00:00
|
|
|
def coverage() {
|
|
|
|
withCredentials([
|
|
|
|
string(credentialsId: 'coveralls-status-react-token', variable: 'COVERALLS_REPO_TOKEN'),
|
|
|
|
]) {
|
|
|
|
nix.shell(
|
|
|
|
'make coverage',
|
2020-02-25 21:42:47 +00:00
|
|
|
keepEnv: ['COVERALLS_REPO_TOKEN', 'COVERALLS_SERVICE_NAME', 'COVERALLS_SERVICE_JOB_ID']
|
2019-07-03 19:00:51 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-21 15:17:25 +00:00
|
|
|
return this
|