forked from ghostery/browser-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.ad-hoc
346 lines (339 loc) · 14.3 KB
/
Jenkinsfile.ad-hoc
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
#!/bin/env groovy
@Library('[email protected]') _
properties([
parameters([
booleanParam(name: 'CLIQZ_ARM', defaultValue: false, description: 'Builds the Cliqz branded `arm` build.'),
booleanParam(name: 'CLIQZ_X86', defaultValue: false, description: 'Builds the Cliqz branded `x86` build.'),
booleanParam(name: 'GHOSTERY_ARM', defaultValue: false, description: 'Builds the Ghostery branded `arm` build.'),
booleanParam(name: 'GHOSTERY_X86', defaultValue: false, description: 'Builds the Ghostery branded `x86` build.'),
booleanParam(name: 'BOND_ARM', defaultValue: false, description: 'Builds the Bond branded `arm` build.'),
booleanParam(name: 'BOND_X86', defaultValue: false, description: 'Builds the Bond branded `x86` build.'),
booleanParam(name: 'CLIQZ_ALPHA_ARM', defaultValue: false, description: 'Builds the Cliqz-Alpha branded `arm` build.'),
booleanParam(name: 'CLIQZ_ALPHA_X86', defaultValue: false, description: 'Builds the Cliqz-Alpha branded `x86` build.'),
booleanParam(name: 'GHOSTERY_ALPHA_ARM', defaultValue: true, description: 'Builds the Ghostery-Alpha branded `arm` build.'),
booleanParam(name: 'GHOSTERY_ALPHA_X86', defaultValue: false, description: 'Builds the Ghostery-Alpha branded `x86` build.')
])
])
def matrix = [
'Cliqz ARM':[
'arch': 'arm',
'brand': 'cliqz',
'channel': 'MA02',
'target': 'arm-linux-androideabi',
'buildParam': params.CLIQZ_ARM,
],
'Cliqz X86':[
'arch': 'x86',
'brand': 'cliqz',
'channel': 'MA02',
'target': 'i686-linux-android',
'buildParam': params.CLIQZ_X86,
],
'Ghostery ARM':[
'arch': 'arm',
'brand': 'ghostery',
'channel': 'MA52',
'target': 'arm-linux-androideabi',
'buildParam': params.GHOSTERY_ARM,
],
'Ghostery X86':[
'arch': 'x86',
'brand': 'ghostery',
'channel': 'MA52',
'target': 'i686-linux-android',
'buildParam': params.GHOSTERY_X86,
],
'Bond ARM':[
'arch': 'arm',
'brand': 'bond',
'channel': 'MA62',
'target': 'arm-linux-androideabi',
'buildParam': params.BOND_ARM,
],
'Bond X86':[
'arch': 'x86',
'brand': 'bond',
'channel': 'MA62',
'target': 'i686-linux-android',
'buildParam': params.BOND_X86,
],
'Cliqz Alpha ARM':[
'arch': 'arm',
'brand': 'cliqz-alpha',
'channel': 'MA02',
'target': 'arm-linux-androideabi',
'buildParam': params.CLIQZ_ALPHA_ARM,
],
'Cliqz Alpha X86':[
'arch': 'x86',
'brand': 'cliqz-alpha',
'channel': 'MA02',
'target': 'i686-linux-android',
'buildParam': params.CLIQZ_ALPHA_X86,
],
'Ghostery Alpha ARM':[
'arch': 'arm',
'brand': 'ghostery-alpha',
'channel': 'MA52',
'target': 'arm-linux-androideabi',
'buildParam': params.GHOSTERY_ALPHA_ARM,
],
'Ghostery Alpha X86':[
'arch': 'x86',
'brand': 'ghostery-alpha',
'channel': 'MA52',
'target': 'i686-linux-android',
'buildParam': params.GHOSTERY_ALPHA_X86,
],
]
def baseImage
def codeImage
def id
node ('master'){
def dockerTag = ""
stage('Checkout') {
checkout scm
dockerTag = readFile('mozilla-release/browser/config/version_display.txt').trim()
}
id = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
baseImageName ="browser-f/android:${dockerTag}"
codeImageName ="browser-f/android:code"
baseImage = stage('Build base image') {
docker.build(baseImageName, '--build-arg UID=`id -u` --build-arg GID=`id -g` -f Dockerfile .')
}
stage('Build code image') {
writeFile file: 'Dockerfile.code', text: """
FROM ${baseImageName}
COPY --chown=jenkins:jenkins . /app/
"""
codeImage = docker.build(
codeImageName,
'-f Dockerfile.code .',
)
}
}
def build(Map m){
def flavorname = m.name
def buildarch = m.arch
def brandname = m.brand
def cliqzchannel = m.channel
def androidtarget = m.target
def getImageName = m.getImageName
def buildParam = m.buildParam
def nodeLabel = 'master'
def getId = m.getId
def apk = ""
def gradleflavor = ""
if (brandname=="bond"){
gradleflavor = "Bond"
} else {
gradleflavor = "Photon"
}
return {
if (buildParam) {
node(nodeLabel) {
getImageName().inside() {
stage('Download cache') {
withCredentials([
[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'f1732e5f-3e84-47ad-9286-a5fa6657ec43',
passwordVariable: 'AWS_SECRET_ACCESS_KEY',
usernameVariable: 'AWS_ACCESS_KEY_ID',
]
]) {
def s3Path = "s3://repository.cliqz.com/dist/android/cache"
def cachePath = ".gradle/caches"
sh """#!/bin/bash -l
set -e
set -x
cd
aws s3 sync --acl public-read --acl bucket-owner-full-control ${s3Path} ${cachePath}
"""
}
}
stage("Build APK: ${flavorname}") {
withEnv([
"ANDROID_TARGET=${androidtarget}",
"BRAND=${brandname}",
"CLIQZ_CHANNEL=${cliqzchannel}"
]){
sh '''#!/bin/bash -l
set -e
set -x
cd /app/mozilla-release
cp ../mozconfigs/deploy.mozconfig mozconfig
./mach clobber
./mach build
export MOZ_CHROME_MULTILOCALE=`ls -1 "../l10n/"|paste -s -d " "`
for AB_CD in $MOZ_CHROME_MULTILOCALE; do
./mach build chrome-$AB_CD
done
export AB_CD=multi
./mach package
'''
withCredentials([
file(credentialsId: 'd746a1dd-e075-4844-869a-32116a496352', variable: 'CERT_PATH' ),
string(credentialsId: 'b7422020-fe1b-4c57-9230-f3d52afee3cf', variable: 'CERT_PASS')
]) {
sh """#!/bin/bash -l
set -e
set -x
cd /app/mozilla-release
export MOZ_CHROME_MULTILOCALE=`ls -1 '../l10n/'|paste -s -d ' '`
export AB_CD=multi
./gradlew assembleOfficialWithGeckoBinariesNoMinApi${gradleflavor}Release
"""
}
apk = sh(returnStdout: true,
script: """cd /app/mozilla-release/objdir-frontend-android/${brandname}/gradle/build/mobile/android/app/outputs/apk/officialWithGeckoBinariesNoMinApi${gradleflavor}/release && \
find *.apk -name '*-release*' -not -name '*-unsigned-*'""").trim()
}
}
stage("Upload: ${flavorname}") {
withCredentials([
[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'f1732e5f-3e84-47ad-9286-a5fa6657ec43',
passwordVariable: 'AWS_SECRET_ACCESS_KEY',
usernameVariable: 'AWS_ACCESS_KEY_ID',
]
]) {
def s3Path = "s3://repository.cliqz.com/dist/android/adhoc/${brandname}"
def apkPath = "/app/mozilla-release/objdir-frontend-android/${brandname}/gradle/build/mobile/android/app/outputs/apk/officialWithGeckoBinariesNoMinApi${gradleflavor}/release/${apk}"
def fileName = "${brandname}_${env.BUILD_NUMBER}_${getId()}"
try {
zip archive: true, dir: "/app/mozilla-release/objdir-frontend-android/${brandname}/gradle/build/mobile/android/app/outputs/apk/officialWithGeckoBinariesNoMinApi${gradleflavor}/release", glob: '', zipFile: "${flavorname}-build.zip"
} catch(e) {
print e
}
if (buildarch=="arm"){
sh """#!/bin/bash -l
set -e
set -x
aws s3 cp --acl public-read --acl bucket-owner-full-control ${apkPath} ${s3Path}/${fileName}.apk
aws s3 cp --acl public-read --acl bucket-owner-full-control ${apkPath} ${s3Path}/latest.apk
"""
} else {
sh """#!/bin/bash -l
set -e
set -x
aws s3 cp --acl public-read --acl bucket-owner-full-control ${apkPath} ${s3Path}/${fileName}_${buildarch}.apk
aws s3 cp --acl public-read --acl bucket-owner-full-control ${apkPath} ${s3Path}/latest_${buildarch}.apk
"""
}
}
}
stage('Clean Up') {
sh '''#!/bin/bash
rm -f /app/mozilla-release/mozconfig
rm -rf /app/mozilla-release/objdir-frontend-android
'''
}
}
}
}
}
}
def stepsForParallelBuilds = helpers.entries(matrix).collectEntries{
[("Building ${it[0]}"):build(
name: it[0],
arch: it[1]['arch'],
brand: it[1]['brand'],
channel: it[1]['channel'],
target: it[1]['target'],
getImageName: {codeImage},
getId: {id},
buildParam: it[1]['buildParam']
)]
}
stage('Build Applications'){
parallel stepsForParallelBuilds
}
stage('Send email') {
def projectName = '$PROJECT_NAME'
def sendMail = false
def bondMail = false
def bodytxt = """
${projectName} - Build # ${env.BUILD_NUMBER}
Check console output at ${env.JOB_URL}${env.BUILD_NUMBER}/ to view the results.
"""
def bodytxtBond = """
${projectName} - Build # ${env.BUILD_NUMBER}
Check console output at ${env.JOB_URL}${env.BUILD_NUMBER}/ to view the results.
"""
if (params.CLIQZ_ARM) {
bodytxt = """${bodytxt}
Cliqz apk Uploaded to: http://repository.cliqz.com.s3.amazonaws.com/dist/android/adhoc/cliqz/cliqz_${env.BUILD_NUMBER}_${id}.apk
"""
sendMail = true
}
if (params.CLIQZ_X86) {
bodytxt = """${bodytxt}
Cliqz X86 apk Uploaded to: http://repository.cliqz.com.s3.amazonaws.com/dist/android/adhoc/cliqz/cliqz_${env.BUILD_NUMBER}_${id}_x86.apk
"""
sendMail = true
}
if (params.GHOSTERY_ARM) {
bodytxt = """${bodytxt}
Ghostery apk Uploaded to: http://repository.cliqz.com.s3.amazonaws.com/dist/android/adhoc/ghostery/ghostery_${env.BUILD_NUMBER}_${id}.apk
"""
sendMail = true
}
if (params.GHOSTERY_X86) {
bodytxt = """${bodytxt}
Ghostery X86 apk Uploaded to: http://repository.cliqz.com.s3.amazonaws.com/dist/android/adhoc/ghostery/ghostery_${env.BUILD_NUMBER}_${id}_x86.apk
"""
sendMail = true
}
if (params.CLIQZ_ALPHA_ARM) {
bodytxt = """${bodytxt}
Cliqz-Alpha apk Uploaded to: http://repository.cliqz.com.s3.amazonaws.com/dist/android/adhoc/cliqz-alpha/cliqz-alpha_${env.BUILD_NUMBER}_${id}.apk
"""
sendMail = true
}
if (params.CLIQZ_ALPHA_X86) {
bodytxt = """${bodytxt}
Cliqz-Alpha apk Uploaded to: http://repository.cliqz.com.s3.amazonaws.com/dist/android/adhoc/cliqz-alpha/cliqz-alpha_${env.BUILD_NUMBER}_${id}_x86.apk
"""
sendMail = true
}
if (params.GHOSTERY_ALPHA_ARM) {
bodytxt = """${bodytxt}
Cliqz-Alpha apk Uploaded to: http://repository.cliqz.com.s3.amazonaws.com/dist/android/adhoc/ghostery-alpha/ghostery-alpha_${env.BUILD_NUMBER}_${id}.apk
"""
sendMail = true
}
if (params.GHOSTERY_ALPHA_X86) {
bodytxt = """${bodytxt}
Cliqz-Alpha apk Uploaded to: http://repository.cliqz.com.s3.amazonaws.com/dist/android/adhoc/ghostery-alpha/ghostery-alpha_${env.BUILD_NUMBER}_${id}_x86.apk
"""
sendMail = true
}
if (params.BOND_ARM) {
bodytxtBond = """${bodytxtBond}
Bond apk Uploaded to: http://repository.cliqz.com.s3.amazonaws.com/dist/android/adhoc/bond/bond_${env.BUILD_NUMBER}_${id}.apk
"""
bondMail = true
}
if (params.BOND_X86) {
bodytxtBond = """${bodytxtBond}
Bond X86 apk Uploaded to: http://repository.cliqz.com.s3.amazonaws.com/dist/android/adhoc/bond/bond_${env.BUILD_NUMBER}_${id}_x86.apk
"""
bondMail = true
}
if (sendMail == true){
emailext(
to: '[email protected]',
subject: '$PROJECT_NAME - Build # $BUILD_NUMBER',
body: bodytxt.stripIndent()
)
}
if (bondMail == true){
emailext(
to: '[email protected]',
subject: 'BOND » ad-hoc builds - Build # $BUILD_NUMBER',
body: bodytxtBond.stripIndent()
)
}
}