-
Notifications
You must be signed in to change notification settings - Fork 40
/
Jenkinsfile
213 lines (186 loc) · 7.37 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
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
import java.text.SimpleDateFormat
//#################################
def repoSync(fullClean, fullReset, manifestRepo, manifestRev, manifestPath){
checkout changelog: true, poll: true, scm: [$class: 'RepoScm', currentBranch: true, \
forceSync: true, jobs: 4, manifestBranch: manifestRev, \
manifestFile: manifestPath, manifestRepositoryUrl: manifestRepo, \
quiet: false, resetFirst: fullClean, resetFirst: fullReset]
}
//#################################
node('jolin') {
stage('Environment'){
def dateFormat = new SimpleDateFormat("yyyyMMdd_HHmm")
def date = new Date()
env.V_RELEASE_TIME = dateFormat.format(date)
env.V_RELEASE_DIR = "release"
env.PATH = "/sbin:" + env.PATH
if(!env.V_BOARD){
env.V_BOARD = "rk3399"
}
if(!env.V_KERNEL_CONFIG){
env.V_KERNEL_CONFIG = "rockchip_defconfig"
}
if(!env.V_LUNCH_VARIANT){
env.V_LUNCH_VARIANT = "userdebug"
}
if(!env.V_ARCH){
env.V_ARCH = "arm64"
}
dir('build-environment') {
checkout changelog: false, poll: false, scm: scm
}
}
def uid = sh (returnStdout: true, script: 'id -u').trim()
def gid = sh (returnStdout: true, script: 'id -g').trim()
def environment = docker.build('android-builder:9.x', "--build-arg USER_ID=${uid} --build-arg GROUP_ID=${gid} build-environment")
environment.inside {
def mVendorList = env.V_VENDOR.split(" ")
def mLunchList = env.V_LUNCHS.split(" ")
stage('repo') {
repoSync(true, true, env.V_REPO_URL, env.V_REPO_BRANCH, env.V_REPO_XML)
}
stage('uboot'){sh '''#!/bin/bash
#uboot
cd u-boot
make distclean
make mrproper
./make.sh "$V_BOARD"
cd -
'''
}
stage('init'){sh '''#!/bin/bash
cd kernel
make distclean
make ARCH="$V_ARCH" "$V_KERNEL_CONFIG"
cd -
rm rockdev
ln -s -f RKTools/linux/Linux_Pack_Firmware/rockdev/ rockdev
rm -rf ${V_RELEASE_DIR}
mkdir -p ${V_RELEASE_DIR}
'''
if (params.FULL_CLEAN_ANDROID){
sh '''#!/bin/bash
rm -rf out/target
'''
}
}
for(vendor in mVendorList){
withEnv(["VENDOR_TMP=" + vendor]){
stage('kernel-' + vendor){sh '''#!/bin/bash
cd kernel
make ARCH="$V_ARCH" ${V_BOARD}-${VENDOR_TMP}.img -j16
cp resource.img resource-${VENDOR_TMP}.img
'''
}
}
}
for(lunch in mLunchList){
withEnv(["LUNCH_TMP=" + lunch]){
stage(lunch){sh '''#!/bin/bash
rm -rf out/target/product/${LUNCH_TMP}/root
rm -rf out/target/product/${LUNCH_TMP}/system
rm -rf out/target/product/${LUNCH_TMP}/recovery
rm -rf out/target/product/${LUNCH_TMP}/vendor
rm -rf out/target/product/${LUNCH_TMP}/oem
rm -f out/target/product/${LUNCH_TMP}/*
. build/envsetup.sh
lunch ${LUNCH_TMP}-${V_LUNCH_VARIANT}
make -j16
'''
}
}
for(vendor in mVendorList){
withEnv(["LUNCH_TMP=" + lunch, "VENDOR_TMP=" + vendor]){
stage('image-' + lunch + '-' + vendor){sh '''#!/bin/bash
. build/envsetup.sh
lunch ${LUNCH_TMP}-${V_LUNCH_VARIANT}
cd kernel
cp -f resource-${VENDOR_TMP}.img resource.img
cd -
if [ "true" == "${V_ANDROID_RESOURCE}" ];then
rm out/target/product/${LUNCH_TMP}/boot.img
make bootimage -j8
fi
./mkimage.sh
cd rockdev
rm -f Image
ln -s -f Image-${LUNCH_TMP} Image
./mkupdate.sh
./android-gpt.sh
cd -
commitId=`git -C .repo/manifests rev-parse --short HEAD`
platform=`get_build_var PLATFORM_VERSION`
release_name="android${platform}-${LUNCH_TMP}-${VENDOR_TMP}-${V_RELEASE_TIME}_${commitId}"
release_title="android${platform}-${V_RELEASE_TIME}"
if [ "$V_RELEASE_TITLE" != "" ];then
release_title="${V_RELEASE_TITLE}-android${platform}-${V_RELEASE_TIME}"
fi
echo "${release_title}" > github-tag
mv rockdev/update.img $V_RELEASE_DIR/${release_name}-rkupdate.img
mv rockdev/Image/gpt.img $V_RELEASE_DIR/${release_name}-gpt.img
cd ${V_RELEASE_DIR}
md5sum ${release_name}-rkupdate.img >> md5
md5sum ${release_name}-gpt.img >> md5
zip ${release_name}-rkupdate.zip ${release_name}-rkupdate.img
zip ${release_name}-gpt.zip ${release_name}-gpt.img
rm -f *.img
cd -
cp -f kernel/resource-${VENDOR_TMP}.img ${V_RELEASE_DIR}
cp -f rockdev/Image/boot.img ${V_RELEASE_DIR}/boot-${VENDOR_TMP}.img
'''
}
}
}
}
stage('release'){
if (params.RELEASE_TO_GITHUB){
sh '''#!/bin/bash
set -xe
shopt -s nullglob
repo manifest -r -o manifest.xml
tag=`cat github-tag`
cd .repo/manifests
V_CHANGE=`sed -r -n '/^>/,/<$/p' RELEASE_NOTE | grep -Ev '(^>|<$)'`
cd -
github-release release \
--target "${V_REPO_BRANCH}" \
--tag "${tag}" \
--name "${tag}" \
--description "${V_CHANGE}" \
--draft
github-release upload \
--tag "${tag}" \
--name "manifest" \
--file "manifest.xml"
github-release upload \
--tag "${tag}" \
--name "md5sum" \
--file "$V_RELEASE_DIR/md5"
for file in $V_RELEASE_DIR/*.zip; do
github-release upload \
--tag "${tag}" \
--name "$(basename "$file")" \
--file "$file" &
done
wait
github-release edit \
--tag "${tag}" \
--name "${tag}" \
--description "${V_CHANGE}"
'''
}
sh'''#!/bin/bash
cp -f rockdev/Image/idbloader.img $V_RELEASE_DIR
cp -f rockdev/Image/parameter.txt $V_RELEASE_DIR
cp -f rockdev/Image/kernel.img $V_RELEASE_DIR
cp -f rockdev/Image/uboot.img $V_RELEASE_DIR
cp -f rockdev/Image/trust.img $V_RELEASE_DIR
'''
script {
archiveArtifacts env.V_RELEASE_DIR + '/*.img'
archiveArtifacts env.V_RELEASE_DIR + '/*.txt'
currentBuild.description = env.V_RELEASE_TIME
}
}
}
}