forked from ghostery/browser-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
145 lines (139 loc) · 4.85 KB
/
Jenkinsfile
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
#!/bin/env groovy
@Library(['cliqz-shared-library@v1.2', 'browser-android@automation']) _
def matrix = [
'cliqz':[
'bundleid': 'com.cliqz.browser',
'target': 'i686-linux-android',
'test': false,
],
'ghostery':[
'bundleid': 'com.ghostery.android.ghostery',
'target': 'i686-linux-android',
'test': true,
],
'cliqz-alpha':[
'bundleid': 'com.cliqz.browser.alpha',
'target': 'arm-linux-androideabi',
'test': false,
],
'ghostery-alpha':[
'bundleid': 'com.ghostery.android.alpha',
'target': 'arm-linux-androideabi',
'test': false,
],
]
def build(Map m){
def androidtarget = m.target
def flavorname = m.name
def bundleid = m.bundleid
def nodeLabel = 'us-east-1 && ubuntu && docker && !gpu'
def test = m.test
return {
node(nodeLabel){
def dockerTag = ""
def apk = ""
def testsFolder = "cliqz-mobile-tests"
setupTestInstance(
test,
"ami-6c24fc11",
"1",
"t2.medium",
"android_ci_genymotion",
"sg-5bbf173f",
"subnet-341ff61f",
"us-east-1"
) {
try {
stage('Checkout') {
checkout scm
dockerTag = readFile('mozilla-release/browser/config/version.txt').trim()
}
def baseImageName = "browser-f/android:${dockerTag}"
docker.withRegistry('https://141047255820.dkr.ecr.us-east-1.amazonaws.com') {
def image = docker.image(baseImageName)
image.pull()
image.inside {
stage('Build Cliqz React Native') {
cliqz.buildCliqzReactNative("cliqz")
}
stage("Build APK: ${flavorname}") {
apk = cliqz.buildBrowser("${androidtarget}", "${flavorname}", "ci")
archiveArtifacts allowEmptyArchive: true, artifacts: "build/${apk}"
}
}
if (test == true){
stage('Checkout Mobile Tests') {
dir("${testsFolder}"){
git branch:'master',
credentialsId: 'cliqz-oss-ci',
url: 'https://github.com/cliqz-oss/cliqz-mobile-tests.git'
}
}
stage("Check Genymotion Status") {
genymotion.genyInstanceStatus()
}
docker.image("${baseImageName}").inside {
withEnv([
"FLAVOR=${flavorname}",
"appPackage=${bundleid}"
]) {
stage('Genymotion ADB Connect') {
genymotion.connectGenyInstance('da5f91e6-e1ca-4aac-94ea-352b6769228b')
}
stage("Run Tests & Upload Results: ${flavorname}") {
timeout(60) {
cliqz.runAppiumTests("${testsFolder}", "${flavorname}", "${apk}")
}
}
}
}
}
}
} catch(e) {
print e
error 'Something Failed ! Check Logs above.'
} finally {
stage('Clean Up') {
utils.cleanUp("${testsFolder}")
}
}
}
}
}
}
def stepsForParallelBuilds = helpers.entries(matrix).collectEntries{
[("Building ${it[0]}"):build(
name: it[0],
bundleid: it[1]['bundleid'],
target:it[1]['target'],
test:it[1]['test']
)]
}
parallel stepsForParallelBuilds
def setupTestInstance(
Boolean inTests,
String instanceImage,
String count,
String instanceType,
String keyName,
String securityGroup,
String subnetId,
String region,
Closure body
) {
if (inTests == true) {
genymotion.withGenymotion(
instanceImage,
count,
instanceType,
keyName,
securityGroup,
subnetId,
region
) {
body()
}
} else {
body()
}
}