-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathrelease.jenkinsfile
More file actions
192 lines (173 loc) · 7.92 KB
/
release.jenkinsfile
File metadata and controls
192 lines (173 loc) · 7.92 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
pipeline {
agent {
label 'ubuntu-18.04 && x64 && hw'
}
options {
// Сколько последних сборок храним?
buildDiscarder(logRotator(numToKeepStr: '10'))
// Отключаем параллельный запуск
disableConcurrentBuilds()
}
environment {
JAVA_HOME = '/usr/lib/jvm/java-8-openjdk-amd64/'
}
stages {
stage('Prepare') {
steps {
withCredentials([
string(credentialsId: 'DGIS_DIRECTORY_APP_KEY', variable: 'DIRECTORY_KEY'),
string(credentialsId: 'DGIS_MAP_API_KEY', variable: 'MAP_KEY'),
string(credentialsId: 'NSDK_UNSTRIPPED_LIBS_BASE_URL', variable: 'UNSTRIPPED_LIBS_URL'),
file(credentialsId: 'NSDK_DEMOAPP_GOOGLE_SERVICES', variable: 'GOOGLE_SERVICES')
]) {
script {
def localProperties = """\
sdk.dir=/opt/android-sdk/
dgisMapApiKey=${env.MAP_KEY}
dgisDirectoryApiKey=${env.DIRECTORY_KEY}
dgisUnstrippedLibsUrl=${env.UNSTRIPPED_LIBS_URL}
""".stripIndent()
writeFile file: "local.properties", text: localProperties
sh 'echo "\ndgisUnstrippedLibsDir=\$(pwd)/build/app/nativeLibs" >> local.properties'
sh "cat ${env.GOOGLE_SERVICES} > app/google-services.json"
}
}
}
}
stage('Build') {
steps {
withCredentials([
usernamePassword(
'credentialsId': 'buildserver-v4core',
'usernameVariable': 'ARTIFACTORY_USERNAME',
'passwordVariable': 'ARTIFACTORY_PASSWORD'
)
]) {
sh(
label: 'Building project',
script: "./gradlew clean build test lint bundle"
)
}
}
}
stage('Test') {
steps {
sh(
label: "Подготовка образа эмулятора",
script: """
echo no | \
/opt/android-sdk/tools/bin/avdmanager \
create avd \
-n webgl-tests \
-k "system-images;android-29;google_apis;x86_64" \
-f
"""
)
timeout(2) {
sh(
label: "Поднятие эмулятора",
script: """
/opt/android-sdk/emulator/emulator \
-memory 2048 \
-partition-size 2048 \
-no-boot-anim \
-noaudio \
-no-snapshot \
-no-window \
-avd webgl-tests > /dev/null 2>&1 &
"""
)
// Скрипт для проверки инициализации эмулятора, т.к. запускаем его не в
// интерактивном режиме.
sh(
label: "Ожидание загрузки эмулятора",
script: """
while [ -z "\$(/opt/android-sdk/platform-tools/adb devices | awk '{print \$2}' | grep device)" ];
do
echo "Waiting for emulator to boot"
sleep 5
done
echo "Emulator booted"
"""
)
}
script {
try {
timeout(10) {
sh(
label: "Подготовка logcat",
script: """
/opt/android-sdk/platform-tools/adb logcat -c
"""
)
sh(
label: "Тесты",
script: "./gradlew connectedAndroidTest --info"
)
}
}
finally {
publishHTML(target: [
reportName: 'App tests results',
alwaysLinkToLastBuild: true,
reportDir: 'build/app/reports/androidTests/connected',
reportFiles: 'index.html',
keepAll: true,
allowMissing: false,
])
timeout(1) {
sh(
label: 'Saving logcat',
script: """
/opt/android-sdk/platform-tools/adb logcat -d > logcat.txt
"""
)
}
archiveArtifacts(artifacts: 'logcat.txt', allowEmptyArchive: true)
}
}
}
}
stage('Signing artifacts') {
steps {
withCredentials([
file(credentialsId: 'RELEASE_KEYSTORE', variable: 'RELEASE_KEYSTORE'),
string(credentialsId: 'RELEASE_KEYSTORE_PASSWORD', variable: 'RELEASE_KEYSTORE_PASSWORD'),
string(credentialsId: 'NSDK_RELEASE_KEY_ALIAS', variable: 'RELEASE_KEY_ALIAS'),
string(credentialsId: 'NSDK_RELEASE_KEY_PASSWORD', variable: 'RELEASE_KEY_PASSWORD'),
]) {
// Signing output bundle
sh """
jarsigner \
-keystore \$RELEASE_KEYSTORE \
-storepass \$RELEASE_KEYSTORE_PASSWORD \
-keypass \$RELEASE_KEY_PASSWORD \
build/app/outputs/bundle/release/app-release.aab \
\$RELEASE_KEY_ALIAS
"""
sh 'jarsigner -verify build/app/outputs/bundle/release/app-release.aab -keystore \$RELEASE_KEYSTORE'
// Signing output apk
sh """
/opt/android-sdk/build-tools/29.0.3/apksigner sign \
--ks \$RELEASE_KEYSTORE \
--key-pass env:RELEASE_KEY_PASSWORD \
--ks-pass env:RELEASE_KEYSTORE_PASSWORD \
--ks-key-alias \$RELEASE_KEY_ALIAS \
--out build/app/outputs/apk/release/app-release.apk \
build/app/outputs/apk/release/app-release-unsigned.apk
"""
sh '/opt/android-sdk/build-tools/29.0.3/apksigner verify build/app/outputs/apk/release/app-release.apk'
}
}
}
stage('Release deploy') {
steps {
sh './gradlew app:uploadCrashlyticsSymbolFileRelease'
archiveArtifacts(artifacts: 'build/app/outputs/apk/release/app-release.apk')
archiveArtifacts(artifacts: 'build/app/outputs/bundle/release/app-release.aab')
archiveArtifacts(artifacts: 'build/app/outputs/apk/debug/app-debug.apk')
archiveArtifacts(artifacts: 'build/app/outputs/bundle/debug/app-debug.aab')
}
}
}
}