Skip to content

Commit aa7abc2

Browse files
committed
Use Dockerfile and Jenkins Docker pipeline to build images
1 parent f47edbf commit aa7abc2

File tree

5 files changed

+117
-209
lines changed

5 files changed

+117
-209
lines changed

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM ubuntu:xenial
2+
3+
RUN apt-get update -y && \
4+
apt-get install -y software-properties-common && \
5+
add-apt-repository -y ppa:openjdk-r/ppa && \
6+
apt-get update -y && \
7+
apt-get install -y openjdk-7-jdk python git-core gnupg flex bison gperf build-essential \
8+
zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \
9+
lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \
10+
libgl1-mesa-dev libxml2-utils xsltproc unzip mtools u-boot-tools \
11+
htop iotop sysstat iftop pigz bc device-tree-compiler lunzip \
12+
dosfstools
13+
14+
RUN curl https://storage.googleapis.com/git-repo-downloads/repo > /usr/local/bin/repo && \
15+
chmod +x /usr/local/bin/repo
16+
17+
RUN curl -L https://github.com/aktau/github-release/releases/download/v0.6.2/linux-amd64-github-release.tar.bz2 | tar -C /tmp -jx && \
18+
mv /tmp/bin/linux/amd64/github-release /usr/local/bin/
19+
20+
RUN which repo && \
21+
which github-release

Jenkinsfile

Lines changed: 96 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,51 @@ properties([
66
booleanParam(defaultValue: false, description: 'If build should be marked as pre-release', name: 'PRERELEASE'),
77
string(defaultValue: 'ayufan-pine64', description: 'GitHub username or organization', name: 'GITHUB_USER'),
88
string(defaultValue: 'android-6.0', description: 'GitHub repository', name: 'GITHUB_REPO'),
9+
booleanParam(defaultValue: true, description: 'Select if you want to build tablet version.', name: 'BUILD_TABLET'),
10+
booleanParam(defaultValue: true, description: 'Select if you want to build TV version.', name: 'BUILD_TV'),
911
])
1012
])
1113
*/
1214

13-
node('digitalocean && ubuntu-16.04 && 8gb && android-6.0') {
14-
stage 'System'
15-
sh '''#!/bin/bash
16-
sudo add-apt-repository -y ppa:openjdk-r/ppa
17-
sudo apt-get update -y
18-
sudo apt-get install -y openjdk-7-jdk python git-core gnupg flex bison gperf build-essential \
19-
zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \
20-
lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \
21-
libgl1-mesa-dev libxml2-utils xsltproc unzip mtools u-boot-tools \
22-
htop iotop sysstat iftop pigz bc device-tree-compiler lunzip
23-
'''
24-
25-
sh '''#!/bin/bash
26-
set -xe
27-
mkdir -p ~/bin
28-
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
29-
chmod a+x ~/bin/repo
30-
'''
31-
32-
ws('/android') {
33-
timestamps {
34-
wrap([$class: 'AnsiColorBuildWrapper', colorMapName: 'xterm']) {
35-
stage 'Prepare'
36-
sh 'rm -f *.gz'
37-
sh "find out/target/product/tulip-chiphd -name 'libatv_uinputbridge.so' -delete"
15+
node('docker && android-build') {
16+
timestamps {
17+
wrap([$class: 'AnsiColorBuildWrapper', colorMapName: 'xterm']) {
18+
stage "Environment"
19+
dir('build-environment') {
20+
checkout scm
21+
}
22+
def environment = docker.build('build-environment:android-6.0', 'build-environment')
3823

24+
environment.inside {
3925
stage 'Sources'
4026
sh '''#!/bin/bash
4127
4228
set -xe
4329
30+
export HOME=$WORKSPACE
31+
export USER=jenkins
32+
33+
repo init -u https://android.googlesource.com/platform/manifest -b android-6.0.1_r74 --depth=1
4434
rm -rf .repo/local_manifests
45-
~/bin/repo init -u https://android.googlesource.com/platform/manifest -b android-6.0.1_r74 --depth=1
4635
git clone https://github.com/ayufan-pine64/local_manifests -b marshmallow .repo/local_manifests
4736
48-
~/bin/repo sync -j 20 -c --force-sync
37+
repo sync -j 20 -c --force-sync
4938
'''
5039

40+
withEnv([
41+
"VERSION=$VERSION",
42+
'TARGET=tulip_chiphd-userdebug',
43+
'USE_CCACHE=true',
44+
'CCACHE_DIR=/var/lib/ccache',
45+
]) {
46+
stage 'Prepare'
47+
sh '''#!/bin/bash
48+
export CCACHE_DIR=$PWD/ccache
49+
prebuilts/misc/linux-x86/ccache/ccache -M 0 -F 0
50+
rm -f *.gz
51+
'''
52+
}
53+
5154
withEnv([
5255
"VERSION=$VERSION",
5356
"CHANGES=$CHANGES",
@@ -60,91 +63,105 @@ node('digitalocean && ubuntu-16.04 && 8gb && android-6.0') {
6063
set -ve
6164
shopt -s nullglob
6265
63-
~/bin/repo manifest -r -o manifest.xml
66+
export HOME=$WORKSPACE
67+
export USER=jenkins
68+
69+
repo manifest -r -o manifest.xml
6470
65-
curl --fail -X PUT -H "Authorization: token $GITHUB_TOKEN" \
66-
-d "{\\"message\\":\\"Add $VERSION changes\\", \\"committer\\":{\\"name\\":\\"Jenkins\\",\\"email\\":\\"[email protected]\\"},\\"content\\":\\"$(echo "$CHANGES" | base64 -w 0)\\"}" \
71+
echo "{\\"message\\":\\"Add $VERSION changes\\", \\"committer\\":{\\"name\\":\\"Jenkins\\",\\"email\\":\\"[email protected]\\"},\\"content\\":\\"$(echo "$CHANGES" | base64 -w 0)\\"}" | \
72+
curl --fail -X PUT -H "Authorization: token $GITHUB_TOKEN" -d @- \
6773
"https://api.github.com/repos/$GITHUB_USER/$GITHUB_REPO/contents/versions/$VERSION/CHANGES.md"
6874
69-
curl --fail -X PUT -H "Authorization: token $GITHUB_TOKEN" \
70-
-d "{\\"message\\":\\"Add $VERSION manifest\\", \\"committer\\":{\\"name\\":\\"Jenkins\\",\\"email\\":\\"[email protected]\\"},\\"content\\":\\"$(base64 -w 0 manifest.xml)\\"}" \
75+
echo "{\\"message\\":\\"Add $VERSION manifest\\", \\"committer\\":{\\"name\\":\\"Jenkins\\",\\"email\\":\\"[email protected]\\"},\\"content\\":\\"$(base64 -w 0 manifest.xml)\\"}" | \
76+
curl --fail -X PUT -H "Authorization: token $GITHUB_TOKEN" -d @- \
7177
"https://api.github.com/repos/$GITHUB_USER/$GITHUB_REPO/contents/versions/$VERSION/manifest.xml"
7278
'''
7379
}
74-
80+
7581
withEnv([
7682
"VERSION=$VERSION",
77-
'TARGET=tulip_chiphd_atv-userdebug',
83+
'TARGET=tulip_chiphd-userdebug',
7884
'USE_CCACHE=true',
79-
'CCACHE_DIR=/ccache',
80-
'ANDROID_JACK_VM_ARGS=-Xmx4g -Dfile.encoding=UTF-8 -XX:+TieredCompilation'
85+
'ANDROID_JACK_VM_ARGS=-Xmx3g -Dfile.encoding=UTF-8 -XX:+TieredCompilation',
86+
'ANDROID_NO_TEST_CHECK=true'
8187
]) {
82-
stage 'TV'
83-
retry(2) {
88+
stage 'Regular'
89+
if (params.BUILD_TABLET) {
8490
sh '''#!/bin/bash
91+
export CCACHE_DIR=$PWD/ccache
92+
export HOME=$WORKSPACE
93+
export USER=jenkins
94+
8595
source build/envsetup.sh
8696
lunch "${TARGET}"
87-
make -j$(($(nproc)+1))
97+
make installclean
8898
'''
89-
}
9099

91-
stage 'Image TV'
92-
sh '''#!/bin/bash
93-
source build/envsetup.sh
94-
lunch "${TARGET}"
95-
set -xe
96-
sdcard_image "${JOB_NAME}-tv-v${VERSION}-r${BUILD_NUMBER}.img.gz"
97-
'''
98-
}
100+
retry(2) {
101+
sh '''#!/bin/bash
102+
export CCACHE_DIR=$PWD/ccache
103+
export HOME=$WORKSPACE
104+
export USER=jenkins
105+
106+
source build/envsetup.sh
107+
lunch "${TARGET}"
108+
make -j$(($(nproc)+1))
109+
'''
110+
}
111+
}
99112

100-
withEnv([
101-
"VERSION=$VERSION",
102-
'TARGET=tulip_chiphd_pinebook-userdebug',
103-
'USE_CCACHE=true',
104-
'CCACHE_DIR=/ccache',
105-
'ANDROID_JACK_VM_ARGS=-Xmx4g -Dfile.encoding=UTF-8 -XX:+TieredCompilation'
106-
]) {
107-
stage 'Pinebook'
108-
retry(2) {
113+
stage 'Image Regular'
114+
if (params.BUILD_TABLET) {
109115
sh '''#!/bin/bash
110116
source build/envsetup.sh
111117
lunch "${TARGET}"
112-
make -j$(($(nproc)+1))
118+
set -xe
119+
sdcard_image "${JOB_NAME}-v${VERSION}-r${BUILD_NUMBER}.img.gz"
113120
'''
114121
}
115-
116-
stage 'Image Pinebook'
117-
sh '''#!/bin/bash
118-
source build/envsetup.sh
119-
lunch "${TARGET}"
120-
set -xe
121-
sdcard_image "${JOB_NAME}-pinebook-v${VERSION}-r${BUILD_NUMBER}.img.gz" pinebook
122-
'''
123122
}
124123

125124
withEnv([
126125
"VERSION=$VERSION",
127-
'TARGET=tulip_chiphd-userdebug',
126+
'TARGET=tulip_chiphd_atv-userdebug',
128127
'USE_CCACHE=true',
129-
'CCACHE_DIR=/ccache',
130-
'ANDROID_JACK_VM_ARGS=-Xmx4g -Dfile.encoding=UTF-8 -XX:+TieredCompilation'
128+
'ANDROID_JACK_VM_ARGS=-Xmx3g -Dfile.encoding=UTF-8 -XX:+TieredCompilation',
129+
'ANDROID_NO_TEST_CHECK=true'
131130
]) {
132-
stage 'Regular'
133-
retry(2) {
131+
stage 'TV'
132+
if (params.BUILD_TV) {
134133
sh '''#!/bin/bash
134+
export CCACHE_DIR=$PWD/ccache
135+
export HOME=$WORKSPACE
136+
export USER=jenkins
137+
135138
source build/envsetup.sh
136139
lunch "${TARGET}"
137-
make -j$(($(nproc)+1))
140+
make installclean
138141
'''
142+
143+
retry(2) {
144+
sh '''#!/bin/bash
145+
export CCACHE_DIR=$PWD/ccache
146+
export HOME=$WORKSPACE
147+
export USER=jenkins
148+
149+
source build/envsetup.sh
150+
lunch "${TARGET}"
151+
make -j$(($(nproc)+1))
152+
'''
153+
}
139154
}
140155

141-
stage 'Image Regular'
142-
sh '''#!/bin/bash
143-
source build/envsetup.sh
144-
lunch "${TARGET}"
145-
set -xe
146-
sdcard_image "${JOB_NAME}-v${VERSION}-r${BUILD_NUMBER}.img.gz"
147-
'''
156+
stage 'Image TV'
157+
if (params.BUILD_TV) {
158+
sh '''#!/bin/bash
159+
source build/envsetup.sh
160+
lunch "${TARGET}"
161+
set -xe
162+
sdcard_image "${JOB_NAME}-tv-v${VERSION}-r${BUILD_NUMBER}.img.gz"
163+
'''
164+
}
148165
}
149166

150167
withEnv([
@@ -159,11 +176,6 @@ node('digitalocean && ubuntu-16.04 && 8gb && android-6.0') {
159176
set -xe
160177
shopt -s nullglob
161178
162-
export PATH=$(pwd)/bin/linux/amd64:$PATH
163-
if ! which github-release; then
164-
curl -L https://github.com/aktau/github-release/releases/download/v0.6.2/linux-amd64-github-release.tar.bz2 | tar jx
165-
fi
166-
167179
github-release release \
168180
--tag "${VERSION}" \
169181
--name "$VERSION: $BUILD_TAG" \

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
# android-6.0
22
Main repository with Android 6.0 releases
3-
4-
## Build snapshot to speed-up build
5-
export DIGITALOCEAN_API_TOKEN=<your-do-token>
6-
packer build -only=digitalocean packer-template.json

packer-template-script.sh

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)