This repository has been archived by the owner on Aug 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathJenkinsfile
317 lines (317 loc) · 16.1 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
#!/usr/bin/env groovy
pipeline {
agent any
environment {
NEXUS_MAVEN = credentials('external-nexus-maven-repo-credentials')
GIT = credentials('github')
COMPONENT_API_EXAMPLE_APP_KEYSTORE_PSW = credentials('gini-vision-library-android_component-api-example-app-release-keystore-password')
COMPONENT_API_EXAMPLE_APP_KEY_PSW = credentials('gini-vision-library-android_component-api-example-app-release-key-password')
SCREEN_API_EXAMPLE_APP_KEYSTORE_PSW = credentials('gini-vision-library-android_screen-api-example-app-release-keystore-password')
SCREEN_API_EXAMPLE_APP_KEY_PSW = credentials('gini-vision-library-android_screen-api-example-app-release-key-password')
EXAMPLE_APP_CLIENT_CREDENTIALS = credentials('gini-vision-library-android_gini-api-client-credentials')
COMPONENT_API_EXAMPLE_APP_HOCKEYAPP_API_TOKEN = credentials('gini-vision-library-android_component-api-example-app-hockeyapp-api-token')
SCREEN_API_EXAMPLE_APP_HOCKEYAPP_API_TOKEN = credentials('gini-vision-library-android_screen-api-example-app-hockeyapp-api-token')
JAVA8 = '/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home'
JAVA11 = '/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home'
}
stages {
stage('Import Pipeline Libraries') {
steps{
library 'android-tools'
}
}
stage('Build') {
when {
anyOf {
not {
branch 'master'
}
allOf {
branch 'master'
expression {
def status = sh(returnStatus: true, script: 'git describe --exact-match HEAD')
return status == 0
}
}
}
}
steps {
sh '''
./gradlew clean \
ginivision:assembleDebug ginivision:assembleRelease \
ginivision-network:assembleDebug ginivision-network:assembleRelease \
ginivision-accounting-network:assembleDebug ginivision-accounting-network:assembleRelease \
-Dorg.gradle.java.home=$JAVA11
'''
}
}
stage('Unit Tests') {
when {
anyOf {
not {
branch 'master'
}
allOf {
branch 'master'
expression {
def status = sh(returnStatus: true, script: 'git describe --exact-match HEAD')
return status == 0
}
}
}
}
steps {
sh './gradlew ginivision:testDebugUnitTest -Dorg.gradle.java.home=$JAVA11'
}
post {
always {
junit allowEmptyResults: true, testResults: 'ginivision/build/outputs/test-results/testDebugUnitTest/*.xml'
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'ginivision/build/reports/tests/testDebugUnitTest', reportFiles: 'index.html', reportName: 'Unit Test Results', reportTitles: ''])
}
}
}
stage('Code Coverage') {
when {
anyOf {
not {
branch 'master'
}
allOf {
branch 'master'
expression {
def status = sh(returnStatus: true, script: 'git describe --exact-match HEAD')
return status == 0
}
}
}
}
steps {
sh './gradlew ginivision:jacocoTestDebugUnitTestReport -Dorg.gradle.java.home=$JAVA11'
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'ginivision/build/jacoco/jacocoHtml', reportFiles: 'index.html', reportName: 'Code Coverage Report', reportTitles: ''])
}
}
stage('Javadoc Coverage') {
when {
anyOf {
not {
branch 'master'
}
allOf {
branch 'master'
expression {
def status = sh(returnStatus: true, script: 'git describe --exact-match HEAD')
return status == 0
}
}
}
}
steps {
sh './gradlew generateJavadocCoverage -Dorg.gradle.java.home=$JAVA8 -PandroidGradlePluginVersion="4.2.2"'
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'ginivision/build/reports/javadoc-coverage', reportFiles: 'index.html', reportName: 'GVL Javadoc Coverage Report', reportTitles: ''])
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'ginivision-network/build/reports/javadoc-coverage', reportFiles: 'index.html', reportName: 'GVL Network Javadoc Coverage Report', reportTitles: ''])
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'ginivision-accounting-network/build/reports/javadoc-coverage', reportFiles: 'index.html', reportName: 'GVL Accounting Network Javadoc Coverage Report', reportTitles: ''])
}
}
stage('Code Analysis') {
when {
anyOf {
not {
branch 'master'
}
allOf {
branch 'master'
expression {
def status = sh(returnStatus: true, script: 'git describe --exact-match HEAD')
return status == 0
}
}
}
}
steps {
sh './gradlew ginivision:lint ginivision:checkstyle ginivision:pmd -Dorg.gradle.java.home=$JAVA11'
sh './gradlew ginivision-network:lint ginivision-network:checkstyle ginivision-network:pmd -Dorg.gradle.java.home=$JAVA11'
sh './gradlew ginivision-accounting-network:lint ginivision-accounting-network:checkstyle ginivision-accounting-network:pmd -Dorg.gradle.java.home=$JAVA11'
androidLint canComputeNew: false, defaultEncoding: '', healthy: '', pattern: 'ginivision/build/reports/lint-results.xml', unHealthy: ''
androidLint canComputeNew: false, defaultEncoding: '', healthy: '', pattern: 'ginivision-network/build/reports/lint-results.xml', unHealthy: ''
androidLint canComputeNew: false, defaultEncoding: '', healthy: '', pattern: 'ginivision-accounting-network/build/reports/lint-results.xml', unHealthy: ''
checkstyle canComputeNew: false, defaultEncoding: '', healthy: '', pattern: 'ginivision/build/reports/checkstyle/checkstyle.xml', unHealthy: ''
checkstyle canComputeNew: false, defaultEncoding: '', healthy: '', pattern: 'ginivision-network/build/reports/checkstyle/checkstyle.xml', unHealthy: ''
checkstyle canComputeNew: false, defaultEncoding: '', healthy: '', pattern: 'ginivision-accounting-network/build/reports/checkstyle/checkstyle.xml', unHealthy: ''
pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: 'ginivision/build/reports/pmd/pmd.xml', unHealthy: ''
pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: 'ginivision-network/build/reports/pmd/pmd.xml', unHealthy: ''
pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: 'ginivision-accounting-network/build/reports/pmd/pmd.xml', unHealthy: ''
}
}
stage('Build Documentation') {
when {
anyOf {
not {
branch 'master'
}
allOf {
branch 'master'
expression {
def status = sh(returnStatus: true, script: 'git describe --exact-match HEAD')
return status == 0
}
}
}
}
steps {
withEnv(["PATH+=/usr/local/bin"]) {
sh 'scripts/build-sphinx-doc.sh'
}
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'ginivision/src/doc/build/html', reportFiles: 'index.html', reportName: 'Documentation', reportTitles: ''])
}
}
stage('Generate Javadoc') {
when {
anyOf {
not {
branch 'master'
}
allOf {
branch 'master'
expression {
def status = sh(returnStatus: true, script: 'git describe --exact-match HEAD')
return status == 0
}
}
}
}
steps {
sh './gradlew ginivision:dokkaHtml ginivision-network:generateJavadoc ginivision-accounting-network:generateJavadoc -Dorg.gradle.java.home=$JAVA8 -PandroidGradlePluginVersion="4.2.2"'
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'ginivision/build/dokka/ginivision', reportFiles: 'index.html', reportName: 'GVL KDoc', reportTitles: ''])
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'ginivision-network/build/docs/javadoc', reportFiles: 'index.html', reportName: 'GVL Network Javadoc', reportTitles: ''])
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'ginivision-accounting-network/build/docs/javadoc', reportFiles: 'index.html', reportName: 'GVL Accounting Network Javadoc', reportTitles: ''])
}
}
stage('Archive Artifacts') {
when {
anyOf {
not {
branch 'master'
}
allOf {
branch 'master'
expression {
def status = sh(returnStatus: true, script: 'git describe --exact-match HEAD')
return status == 0
}
}
}
}
steps {
sh 'cd ginivision/build/jacoco && zip -r testCoverage.zip jacocoHtml && cd -'
sh 'cd ginivision/build/reports && zip -r javadocCoverage.zip javadoc-coverage && cd -'
archiveArtifacts 'ginivision/build/outputs/aar/*.aar,ginivision/build/jacoco/testCoverage.zip,ginivision/build/reports/javadocCoverage.zip'
}
}
stage('Build Example Apps') {
when {
anyOf {
not {
branch 'master'
}
allOf {
branch 'master'
expression {
def status = sh(returnStatus: true, script: 'git describe --exact-match HEAD')
return status == 0
}
}
}
}
steps {
sh '''
./gradlew screenapiexample::clean screenapiexample::assembleRelease \
-PreleaseKeystoreFile=screen_api_example.jks -PreleaseKeystorePassword="$SCREEN_API_EXAMPLE_APP_KEYSTORE_PSW" \
-PreleaseKeyAlias=screen_api_example -PreleaseKeyPassword="$SCREEN_API_EXAMPLE_APP_KEY_PSW" \
-PclientId=$EXAMPLE_APP_CLIENT_CREDENTIALS_USR -PclientSecret=$EXAMPLE_APP_CLIENT_CREDENTIALS_PSW \
-Dorg.gradle.java.home=$JAVA11
'''
sh '''
./gradlew componentapiexample::clean componentapiexample::assembleRelease \
-PreleaseKeystoreFile=component_api_example.jks -PreleaseKeystorePassword="$COMPONENT_API_EXAMPLE_APP_KEYSTORE_PSW" \
-PreleaseKeyAlias=component_api_example -PreleaseKeyPassword="$COMPONENT_API_EXAMPLE_APP_KEY_PSW" \
-PclientId=$EXAMPLE_APP_CLIENT_CREDENTIALS_USR -PclientSecret=$EXAMPLE_APP_CLIENT_CREDENTIALS_PSW \
-Dorg.gradle.java.home=$JAVA11
'''
archiveArtifacts '''
screenapiexample/build/outputs/apk/release/screenapiexample-release.apk,\
componentapiexample/build/outputs/apk/release/componentapiexample-release.apk,\
screenapiexample/build/outputs/mapping/release/mapping.txt,\
componentapiexample/build/outputs/mapping/release/mapping.txt \
-Dorg.gradle.java.home=$JAVA11
'''
}
}
stage('Release Documentation') {
when {
expression {
def status = sh(returnStatus: true, script: 'git describe --exact-match HEAD')
return status == 0
}
expression {
boolean publish = false
try {
def version = sh(returnStdout: true, script: './gradlew -q printLibraryVersion -Dorg.gradle.java.home=$JAVA11').trim()
def sha = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim()
input "Release documentation for ${version} from branch ${env.BRANCH_NAME} commit ${sha}?"
publish = true
} catch (final ignore) {
publish = false
}
return publish
}
}
steps {
sh 'scripts/release-javadoc.sh $GIT_USR $GIT_PSW'
sh 'scripts/release-doc.sh $GIT_USR $GIT_PSW'
}
}
stage('Release Library Snapshot') {
when {
branch 'develop'
}
steps {
sh '''
./gradlew publishReleasePublicationToSnapshotsRepository \
-PmavenSnapshotsRepoUrl=https://repo.gini.net/nexus/content/repositories/snapshots \
-PrepoUser=$NEXUS_MAVEN_USR \
-PrepoPassword=$NEXUS_MAVEN_PSW \
-Dorg.gradle.java.home=$JAVA11
'''
}
}
stage('Release Library') {
when {
expression {
def status = sh(returnStatus: true, script: 'git describe --exact-match HEAD')
return status == 0
}
expression {
boolean publish = false
try {
def version = sh(returnStdout: true, script: './gradlew -q printLibraryVersion -Dorg.gradle.java.home=$JAVA11').trim()
def sha = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim()
input "Release ${version} from branch ${env.BRANCH_NAME} commit ${sha}?"
publish = true
} catch (final ignore) {
publish = false
}
return publish
}
}
steps {
sh '''
./gradlew publishReleasePublicationToOpenRepository \
-PmavenOpenRepoUrl=https://repo.gini.net/nexus/content/repositories/open \
-PrepoUser=$NEXUS_MAVEN_USR \
-PrepoPassword=$NEXUS_MAVEN_PSW \
-Dorg.gradle.java.home=$JAVA11
'''
}
}
}
}