forked from ghostery/browser-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile.docker
86 lines (81 loc) · 3.7 KB
/
Jenkinsfile.docker
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
#!/bin/env groovy
node('us-east-1 && ubuntu && docker && !gpu') {
def dockerTag
stage('Checkout') {
checkout scm
dockerTag = readFile('mozilla-release/browser/config/version_display.txt').trim()
}
def baseImageName = "browser-f/android:${dockerTag}"
stage('Build Create Docker Image') {
docker.withRegistry('https://141047255820.dkr.ecr.us-east-1.amazonaws.com'){
def baseImage = docker.build(baseImageName, '--build-arg UID=`id -u` --build-arg GID=`id -g` .')
baseImage.push dockerTag
}
}
docker.image("141047255820.dkr.ecr.us-east-1.amazonaws.com/${baseImageName}").inside {
try {
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 APK') {
writeFile file: 'mozconfig.txt', text: '''
# Build Firefox for Android:
ac_add_options --enable-application=mobile/android
ac_add_options --target=arm-linux-androideabi
# With the following Android SDK and NDK:
ac_add_options --with-android-sdk=/home/jenkins/.mozbuild/android-sdk-linux
ac_add_options --with-adjust-sdk-keyfile="$topsrcdir/mobile/android/base/adjust-sdk-sandbox.token"
ac_add_options --with-android-ndk=/home/jenkins/.mozbuild/android-ndk-linux/android-ndk-r18b
# Write build artifacts to:
mk_add_options MOZ_OBJDIR=./objdir-frontend-android/
'''
sh '''#!/bin/bash -l
set -e
set -x
export GRADLE_MAVEN_REPOSITORIES="https://dl.google.com/dl/android/maven2/","https://jcenter.bintray.com/"
cd mozilla-release
cp ../mozconfig.txt mozconfig
./mach build
'''
}
stage('Upload 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
cd
aws s3 rm $s3Path --recursive
aws s3 cp ${cachePath} $s3Path --recursive
"""
}
}
}
finally {
stage('Clean Up') {
sh '''#!/bin/bash -l
rm -f mozilla-release/mozconfig
rm -rf mozilla-release/objdir-frontend-android
'''
}
}
}
}