Commit 0dceb2c7 authored by Konstantin Tskhovrebov's avatar Konstantin Tskhovrebov 🤖

refactored ci parameters for gradle build

parent 1a6733c8
......@@ -3,6 +3,7 @@ image: jangrewe/gitlab-ci-android
before_script:
- export GRADLE_USER_HOME=$(pwd)/.gradle
- export BUILD_NUMBER=$(git rev-list --count ${CI_BUILD_REF})
- export BUILD_COMMIT_SHA=${CI_COMMIT_SHA}
- chmod +x ./gradlew
cache:
......
......@@ -2,8 +2,6 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
//CI
apply from: '../ci.gradle'
android {
......@@ -14,8 +12,8 @@ android {
applicationId "ru.terrakok.gitlabclient"
minSdkVersion 19
targetSdkVersion 27
versionName "1.0"
// versionCode 1 get it from '../ci.gradle'
versionName "1.0 (" + getBuildUid() + ")"
versionCode getBuildNumber()
buildConfigField "String", "WEB_AUTH_USER_AGENT", '"gitfox_user_agent"'
buildConfigField "String", "ORIGIN_GITLAB_ENDPOINT", '"https://gitlab.com/"'
......@@ -37,7 +35,7 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationIdSuffix '.debugPG'
versionNameSuffix ' (debugPG)'
versionNameSuffix ' debugPG'
}
release {
......
android.defaultConfig.versionCode = getBuildNumber()
ext.getBuildNumber = {
(System.env.BUILD_NUMBER ?: 1) as int
}
static Integer getBuildNumber() {
if (System.env.BUILD_NUMBER != null) {
return Integer.parseInt(System.env.BUILD_NUMBER)
}
return 1
ext.getBuildUid = {
System.env.BUILD_COMMIT_SHA ?: "local"
}
gradle.buildFinished {
println('VersionName: ' + android.defaultConfig.versionName)
println('VersionCode: ' + android.defaultConfig.versionCode)
println("VersionName: ${android.defaultConfig.versionName}")
println("VersionCode: ${getBuildNumber()}")
println("BuildUid: ${getBuildUid()}")
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment