forked from ghostery/browser-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile.artifact
128 lines (122 loc) · 5.76 KB
/
Jenkinsfile.artifact
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
#!/bin/env groovy
@Library('cliqz-shared-library@v1.2') _
properties([
parameters([
booleanParam(name: 'REPLACE_TARGET', defaultValue: false, description: 'Replaces the existing target.apk from S3')
])
])
def matrix = [
'x86':[
'target':'i686-linux-android',
],
'arm':[
'target':'arm-linux-androideabi',
],
]
def build(Map m){
def target = m.target
def nodeLabel = 'us-east-1 && ubuntu && docker && !gpu'
def arch = m.name
return {
node(nodeLabel) {
def version = ((("https://raw.githubusercontent.com/cliqz-oss/cliqz-android/master/mozilla-release/browser/config/version.txt").toURL()).getText()).trim()
def url = "https://repository.cliqz.com/dist/android/artifacts/${version}"
def createTarget = false
if (!params.REPLACE_TARGET) {
try {
def targetAPK = sh(returnStdout: true,
script: """wget -S --spider '${url}/${arch}/cliqz-target.apk' 2>&1 | grep 'HTTP/1.1 200 OK'""").trim()[-2..-1]
} catch(e) {
createTarget = true
}
}
else {
createTarget = true
}
if (createTarget) {
def dockerTag = ""
def apk = ""
try {
stage('Checkout') {
checkout scm
dockerTag = readFile('mozilla-release/browser/config/version_display.txt').trim()
}
def baseImageName = "browser-f/android:${dockerTag}"
docker.withRegistry('https://141047255820.dkr.ecr.us-east-1.amazonaws.com') {
docker.image("${baseImageName}").inside {
stage('Download cache') {
withCredentials([[
$class: 'AmazonWebServicesCredentialsBinding',
accessKeyVariable: 'AWS_ACCESS_KEY_ID',
credentialsId: 'd7e38c4a-37eb-490b-b4da-2f53cc14ab1b',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY']]) {
def s3Path = "s3://repository.cliqz.com/dist/android/cache"
def cachePath = ".gradle/caches"
sh """#!/bin/bash -l
pip install awscli --upgrade --user
cd
aws s3 cp --acl public-read --acl bucket-owner-full-control ${s3Path} ${cachePath} --recursive
"""
}
}
stage('Build Artifacts') {
withEnv(["ANDROID_TARGET=${target}"]) {
sh '''#!/bin/bash -l
set -e
set -x
cp mozconfigs/artifact.mozconfig mozilla-release/mozconfig
cd mozilla-release
./mach clobber
./mach -v build
./mach -v package
'''
}
}
stage('Upload to S3'){
apk = sh(returnStdout: true,
script: """cd mozilla-release/objdir-frontend-android/dist && \
find *.apk -name 'target*' -not -name '*-unsigned-*'""").trim()
sh "cp mozilla-release/objdir-frontend-android/dist/${apk} target.apk"
archiveArtifacts allowEmptyArchive: true, artifacts: 'target.apk'
withCredentials([
[
$class: 'AmazonWebServicesCredentialsBinding',
accessKeyVariable: 'AWS_ACCESS_KEY_ID',
credentialsId: 'd7e38c4a-37eb-490b-b4da-2f53cc14ab1b',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
]
]) {
def s3Path = "s3://repository.cliqz.com/dist/android/artifacts/${version}/${arch}"
if (!params.REPLACE_TARGET) {
sh """#!/bin/bash -l
aws s3 rm $s3Path/cliqz-target.apk
"""
}
sh """#!/bin/bash -l
aws s3 cp target.apk $s3Path/cliqz-target.apk
"""
}
}
}
}
}
finally {
stage('Clean Up') {
sh '''#!/bin/bash
rm -f target.apk
rm -f mozilla-release/mozconfig
rm -rf mozilla-release/objdir-frontend-android
'''
}
}
}
}
}
}
def stepsForParallelBuilds = helpers.entries(matrix).collectEntries{
[("ARCH: ${it[0]}"):build(
name: it[0],
target: it[1]['target']
)]
}
parallel stepsForParallelBuilds