-
Notifications
You must be signed in to change notification settings - Fork 96
/
Jenkinsfile
318 lines (286 loc) · 14 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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
pipeline {
agent none
options {
timeout(time: 4, unit: 'HOURS')
buildDiscarder(logRotator(numToKeepStr: '5', artifactNumToKeepStr: '5'))
parallelsAlwaysFailFast()
}
environment {
// Environment variables needed for the github-release tool
GITHUB_TOKEN = credentials('github-boden-release-token')
GITHUB_USER = 'AshampooSystems'
GITHUB_REPO = 'boden'
}
stages {
stage('Checks') {
parallel {
stage('Formatting') {
environment {
BAUER_PLATFORM = 'android'
BAUER_BUILD_SYSTEM = 'make'
BAUER_CONFIG = 'Release'
BAUER_PACKAGE_FOLDER = 'package'
BAUER_PACKAGE_GENERATOR = 'TGZ'
}
agent {
dockerfile {
filename 'docker/Dockerfile_android'
additionalBuildArgs '-t boden_android'
label 'boden'
}
}
stages {
stage('Run clang-format') {
steps {
sh 'python boden.py build -a x86_64 --target FormatSources'
}
}
stage('Check for changes') {
steps {
script {
List<String> sourceChanged = sh(returnStdout: true, script: "git diff --name-only").split()
if(sourceChanged.size() > 0) {
String changedFiles = "Some files were changed by clang-format, make sure to format before committing:\n";
for (int i = 0; i < sourceChanged.size(); i++) {
changedFiles += sourceChanged[i] + "\n";
if(i > 10) {
changedFiles += "...\n";
break;
}
}
println changedFiles
error(changedFiles)
}
}
}
}
}
}
stage('mkdocs') {
agent {
dockerfile {
filename 'docker/Dockerfile_mkdocs'
label 'boden-general'
additionalBuildArgs '--build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g)'
}
}
steps {
sh '/usr/bin/python3 -m pip install -r docs/requirements.txt'
sh 'cd docs && /usr/bin/python3 check-docs.py'
}
}
}
}
stage('Platforms') {
parallel {
stage('Android - Linux') {
environment {
BAUER_PLATFORM = 'android'
BAUER_CONFIG = 'Release'
BAUER_PACKAGE_FOLDER = 'package'
BAUER_PACKAGE_GENERATOR = 'TGZ'
}
agent {
dockerfile {
filename 'docker/Dockerfile_android'
additionalBuildArgs '-t boden_android'
label 'boden'
}
}
stages {
stage('Build') {
steps {
sh 'python boden.py prepare -b make -a arm64-v8a'
sh 'python boden.py prepare -b make -a x86_64'
// This is only necessary for testing, move out once tests work again
sh 'python boden.py prepare -a x86_64 -b AndroidStudio'
sh 'python boden.py build -b AndroidStudio $BUILD_EXTRA_ARGS'
stash includes: 'build/android/**/*', name: 'android-build-data'
}
}
/*stage('Package') {
steps {
sh 'python boden.py package -p android -b AndroidStudio $BUILD_EXTRA_ARGS'
archiveArtifacts artifacts: 'build/package/boden-*.tar.gz', fingerprint: true
stash includes: 'build/package/*', name: 'android-packages'
}
}*/
/*stage('Test') {
steps {
sh 'mkdir -p testresults'
sh 'xvfb-run --server-args=\'-screen 0, 1024x768x16\' -- python boden.py run --target testboden -- --out testresults/android_testboden.xml --reporter junit --reporter console --print-level 2 || true'
junit "testresults/android_testboden.xml"
sh 'xvfb-run --server-args=\'-screen 0, 1024x768x16\' -- python boden.py run --target testbodenui -- --out testresults/android_testbodenui.xml --reporter junit --reporter console --print-level 2 || true'
junit "testresults/android_testbodenui.xml"
archiveArtifacts artifacts: 'testresults/*.xml'
}
}*/
stage('Test boden new') {
steps {
sh 'python boden.py new -n testapp && cd testapp && python ../boden.py build -p android'
}
}
}
}
/*
// Note: this is separate because we need to use a separate
// docker image as the basis. A docker that can build and test
// android apps reaches the limits for the maximum container size
// that AWS ECS Fargate allows.
stage('Android Test') {
environment {
BAUER_PLATFORM = 'android'
BAUER_CONFIG = 'Release'
BAUER_PACKAGE_FOLDER = 'package'
BAUER_PACKAGE_GENERATOR = 'TGZ'
}
agent {
label 'linux-test-android'
}
stages {
stage('Test') {
steps {
unstash 'android-build-data'
sh 'mkdir -p testresults'
sh 'xvfb-run --server-args=\'-screen 0, 1024x768x16\' -- python boden.py run --target testboden -- --out testresults/android_testboden.xml --reporter junit --reporter console --print-level 2 || true'
junit "testresults/android_testboden.xml"
sh 'xvfb-run --server-args=\'-screen 0, 1024x768x16\' -- python boden.py run --target testbodenui -- --out testresults/android_testbodenui.xml --reporter junit --reporter console --print-level 2 || true'
junit "testresults/android_testbodenui.xml"
archiveArtifacts artifacts: 'testresults/*.xml'
}
}
}
}*/
stage('IOS') {
environment {
BAUER_PLATFORM = 'ios'
BAUER_BUILD_SYSTEM = 'make'
BAUER_CONFIG = 'Release'
BAUER_PACKAGE_FOLDER = 'package'
BAUER_PACKAGE_GENERATOR = 'TGZ'
BAUER_IDENTITY = 'iPhone Developer'
}
agent { label 'iOS' }
stages {
stage('Build') {
steps {
sh 'python boden.py build'
}
}
stage('Package') {
steps {
sh 'python boden.py package'
archiveArtifacts artifacts: 'build/package/boden-*.tar.gz', fingerprint: true
stash includes: 'build/package/*', name: 'ios-packages'
}
}
stage('Sign') {
environment {
JENKINS_USER = credentials('mac-jenkins-user')
BAUER_KEYCHAIN = credentials('jenkins-dev-certificate-keychain')
}
steps {
sh 'python boden.py codesign --password $JENKINS_USER_PSW'
}
}
stage('Test') {
steps {
sh 'mkdir -p testresults'
sh 'python boden.py run --target testBoden -- --gtest_output=xml:$PWD/testresults/ios_testBoden.xml'
sh 'cat $PWD/testresults/ios_testBoden.xml'
junit "testresults/ios_testBoden.xml"
archiveArtifacts artifacts: 'testresults/ios_testBoden.xml'
}
}
stage('Test boden new') {
steps {
sh 'python boden.py new -n testapp && cd testapp && python ../boden.py build -p ios'
}
}
}
}
/*
stage('Android - Windows') {
environment {
BAUER_PLATFORM = 'android'
BAUER_CONFIG = 'Release'
BAUER_PACKAGE_FOLDER = 'package'
BAUER_PACKAGE_GENERATOR = 'TGZ'
}
agent { label 'boden-win' }
stages {
stage('Build') {
steps {
bat 'python boden.py prepare -a x86_64'
//bat 'python boden.py prepare -a arm64-v8a'
bat 'python boden.py build -a x86_64 %BUILD_EXTRA_ARGS%'
//bat 'python boden.py build -a arm64-v8a %BUILD_EXTRA_ARGS%'
}
}
stage('Test boden new') {
steps {
bat 'python boden.py new -n testapp && cd testapp && python ../boden.py build -a x86_64'
}
}
}
}
*/
}
}
stage('Deployment') {
parallel {
stage('mkdocs') {
when {
branch "master"
}
agent {
dockerfile {
filename 'docker/Dockerfile_mkdocs'
label 'boden-general'
additionalBuildArgs '--build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g)'
}
}
steps {
withCredentials([sshUserPrivateKey(credentialsId: 'deploy-boden', keyFileVariable: 'SSH_KEY', usernameVariable: 'SSH_USER')]) {
sh 'git remote add documentation [email protected]:AshampooSystems/boden-private.git || true'
sh '/usr/bin/python3 -m pip install -r docs/requirements.txt'
withEnv(["GIT_SSH_COMMAND=ssh -o StrictHostKeyChecking=no -o User=${SSH_USER} -i ${SSH_KEY}"]) {
sh 'cd docs && /usr/bin/python3 -m mkdocs gh-deploy --force -c --remote-name documentation'
}
}
}
}
stage('Release') {
when {
branch "release/*"
}
agent {
dockerfile {
filename 'docker/Dockerfile_github'
args '--volume ${WORKSPACE}:/boden'
label 'boden-general'
}
}
steps {
/*unstash 'android-packages'*/
unstash 'ios-packages'
unstash 'macos-packages'
unstash 'linux-packages'
script {
env.RELEASE_NAME = env.BRANCH_NAME.split('/')[1]
}
sh 'github-release delete --tag $RELEASE_NAME || true'
sh 'github-release release --target $GIT_COMMIT --tag $RELEASE_NAME --name "boden - $RELEASE_NAME"'
sh 'ls /boden/build/package'
sh 'cd build/package && find . -exec sh -c \'github-release upload --tag $RELEASE_NAME --name $(basename $0) --file $0\' {} ";"'
}
}
}
}
}
post {
failure {
slackSend (color: '#FF0000', channel: "boden-ci", message: "@here: FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
}
}