This repository has been archived by the owner on Sep 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathJenkinsfile.nightlyadhoc
243 lines (236 loc) · 8.83 KB
/
Jenkinsfile.nightlyadhoc
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
#!/bin/env groovy
@Library(['[email protected]', 'browser-android@automation']) _
properties([
pipelineTriggers([cron(env.BRANCH_NAME == 'master' ? 'H 23 * * * ' : '')]),
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: true, description: 'Builds the Ghostery branded `arm` build.'),
booleanParam(name: 'GHOSTERY_ARM64', defaultValue: true, description: 'Builds the Ghostery branded `arm` build.'),
booleanParam(name: 'GHOSTERY_X86', defaultValue: true, description: 'Builds the Ghostery branded `x86` build.'),
booleanParam(name: 'GHOSTERY_X86_64', defaultValue: true, description: 'Builds the Ghostery 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: false, 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 ARM64':[
'arch': 'arm64',
'brand': 'ghostery',
'channel': 'MA52',
'target': 'aarch64-linux-android',
'buildParam': params.GHOSTERY_ARM64,
],
'Ghostery X86':[
'arch': 'x86',
'brand': 'ghostery',
'channel': 'MA52',
'target': 'i686-linux-android',
'buildParam': params.GHOSTERY_X86,
],
'Ghostery X86_64':[
'arch': 'x86',
'brand': 'ghostery',
'channel': 'MA52',
'target': 'x86_64-linux-android',
'buildParam': params.GHOSTERY_X86_64,
],
'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 id
def volumeStr
node ('kria'){
def dockerTag = ""
stage('Checkout') {
checkout scm
dockerTag = readFile('mozilla-release/browser/config/version.txt').trim()
sh """#!/bin/bash -l
rm -rf mozilla-release/objdir-frontend-android
"""
}
id = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
volumeStr = "$WORKSPACE"
baseImageName ="browser-f/android:${dockerTag}"
baseImage = stage('Build base image') {
docker.build(baseImageName, '--build-arg USER=`whoami` --build-arg UID=`id -u` --build-arg GID=`id -g` -f Dockerfile .')
}
}
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 = 'kria'
def getId = m.getId
def apk = ""
def volumeStr = m.volumeStr
return {
if (buildParam) {
node(nodeLabel) {
getImageName().inside("-v '${volumeStr()}:/orig'") {
try{
stage('Add Repo') {
cliqz.rSyncRepo("/orig/", "/app/")
}
stage('Build Cliqz React Native') {
cliqz.buildCliqzReactNative("/app/cliqz")
}
stage("Build APK: ${flavorname}") {
withCredentials([
file(credentialsId: 'd746a1dd-e075-4844-869a-32116a496352', variable: 'CERT_PATH' ),
string(credentialsId: 'b7422020-fe1b-4c57-9230-f3d52afee3cf', variable: 'CERT_PASS')
]) {
apk = cliqz.buildBrowser("${androidtarget}", "${brandname}", "nightly", "/app")
}
}
stage("Upload: ${flavorname}") {
withCredentials([
[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'f1732e5f-3e84-47ad-9286-a5fa6657ec43',
passwordVariable: 'AWS_SECRET_ACCESS_KEY',
usernameVariable: 'AWS_ACCESS_KEY_ID',
]
]) {
archiveArtifacts allowEmptyArchive: true, artifacts: "/app/build/${apk}"
utils.s3Copy(
"/app/build/${apk}",
"s3://repository.cliqz.com/dist/android/nightly/${brandname}",
"${brandname}_${env.BUILD_NUMBER}_${getId()}",
"${buildarch}",
true
)
}
}
} catch(e) {
print e
error 'Something Failed ! Check Logs above.'
} finally {
stage('Clean Up') {
utils.cleanUp()
}
}
}
}
}
}
}
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: {baseImage},
getId: {id},
buildParam: it[1]['buildParam'],
volumeStr: {volumeStr}
)]
}
stage('Build Applications'){
parallel stepsForParallelBuilds
}
def transitionIssueList
def passedBuilds
stage('JIRA'){
withEnv(['JIRA_SITE=cliqztix']){
def returnList = jira.transitionIssues()
passedBuilds = returnList[0]
transitionIssueList = returnList[1]
}
}
stage('Send email') {
def projectName = '$PROJECT_NAME'
def changesSinceLastSuccess = jira.getChangeString(passedBuilds)
def bodytxt = """
${projectName} - Build # ${env.BUILD_NUMBER}
Check console output at ${env.JOB_URL}${env.BUILD_NUMBER}/ to view the results.
"""
params.each { prop, val ->
if(prop != "BRANCH"){
if(val){
def splitText = prop.toString().toLowerCase().split("_")
def brand = ""
def suffix = ""
if (splitText.size()==3){
if (splitText[2] == "x86"){
suffix = "_x86"
}
brand = "${splitText[0]}-${splitText[1]}"
} else {
if (splitText[1] == "x86"){
suffix = "_x86"
}
brand = "${splitText[0]}"
}
bodytxt = """${bodytxt}
${brand}${suffix} apk Uploaded to: http://repository.cliqz.com.s3.amazonaws.com/dist/android/nightly/${brand}/${brand}_${env.BUILD_NUMBER}_${id}${suffix}.apk
"""
}
}
}
bodytxt="""${bodytxt}
${changesSinceLastSuccess}
Issues Transtioned ${transitionIssueList}
"""
emailext(
to: '[email protected]',
subject: '$PROJECT_NAME - Build # $BUILD_NUMBER',
body: bodytxt.stripIndent()
)
}