-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkins_build.sh
83 lines (68 loc) · 2.16 KB
/
jenkins_build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# input params
#productFlavour=$1
#versionCode=$2
#versionName=$3
#buildType=$4
productFlavour="qa"
versionCode="2"
versionName="2.0"
buildType="release"
#storePass=$6
#keyAlias=$7
#keyPass=$8
# -----------------------------------------------------------------
# ------------------------------ BUILD ----------------------------
# -----------------------------------------------------------------
propertiesFile='gradle.properties'
chmod +x ${propertiesFile}
# helper method
setProperty() {
sed -i -e "s/\($1 *= *\).*/$1=$2/g" ${propertiesFile}
}
# update key properties based on build type
(setProperty "versionCode" $versionCode)
(setProperty "versionName" $versionName)
#if [ $buildType = 'debug' ]; then
# (setProperty "KEYSTORE" "debug.keystore")
# (setProperty "STORE_PASSWORD" "android")
# (setProperty "KEY_ALIAS" "androiddebugkey")
# (setProperty "KEY_PASSWORD" "android")
#elif [ $buildType = 'release' ]; then
# (setProperty "KEYSTORE" "smb-apps.jks")
# (setProperty "STORE_PASSWORD" "$storePass")
# (setProperty "KEY_ALIAS" "$keyAlias")
# (setProperty "KEY_PASSWORD" "$keyPass")
#fi
# clean project
chmod +x gradlew
./gradlew clean --stacktrace
# build
capitalize()
{
value=$1
value=${value,,}
value=${value^}
echo $value
}
#if [ $productFlavour = 'null' ]; then
./gradlew "assemble"`capitalize $buildType` --stacktrace
#else
#./gradlew "assemble"`capitalize $productFlavour``capitalize $buildType` --stacktrace
#if [ $buildType = 'debug' ]; then
# ./gradlew assembleDebug --stacktrace
#elif [ $buildType = 'release' ]; then
# ./gradlew assembleRelease --stacktrace
#fi
# -----------------------------------------------------------------
# -------------------------- POST BUILD ---------------------------
# -----------------------------------------------------------------
apkFileName="jenkins-v$versionName-$productFlavour-$buildType.apk"
rm -r artifacts/
mkdir artifacts
# copy apk to artifacts
if [ ! -e "app/build/outputs/apk/$productFlavour/$buildType/$apkFileName" ]; then
echo "ERROR: File not exists: (app/build/outputs/apk/$productFlavour/$buildType/$apkFileName)"
exit 1
fi
cp app/build/outputs/apk/$productFlavour/$buildType/$apkFileName artifacts/