@@ -9,11 +9,12 @@ pipeline {
9
9
environment {
10
10
GIT_NAME = " volto-block-style"
11
11
NAMESPACE = " @eeacms"
12
- SONARQUBE_TAGS = " volto.eea.europa.eu,climate-energy.eea.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,sustainability.eionet.europa.eu, industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,climate-adapt.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-en"
12
+ SONARQUBE_TAGS = " volto.eea.europa.eu,climate-energy.eea.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,climate-adapt.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-en,insitu-frontend.eionet.europa.eu,insitu.copernicus.eu "
13
13
DEPENDENCIES = " "
14
14
BACKEND_PROFILES = " eea.kitkat:testing"
15
15
BACKEND_ADDONS = " "
16
- VOLTO = " 16"
16
+ VOLTO = " 17"
17
+ VOLTO16_BREAKING_CHANGES = " no"
17
18
IMAGE_NAME = BUILD_TAG . toLowerCase()
18
19
}
19
20
@@ -44,6 +45,7 @@ pipeline {
44
45
}
45
46
steps {
46
47
script {
48
+ checkout scm
47
49
withCredentials([string(credentialsId : ' eea-jenkins-token' , variable : ' GITHUB_TOKEN' )]) {
48
50
check_result = sh script : ''' docker run --pull always -i --rm --name="$IMAGE_NAME-gitflow-check" -e GIT_TOKEN="$GITHUB_TOKEN" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_ORG="$GIT_ORG" -e GIT_NAME="$GIT_NAME" eeacms/gitflow /check_if_testing_needed.sh''' , returnStatus : true
49
51
@@ -61,33 +63,34 @@ pipeline {
61
63
allOf {
62
64
not { environment name : ' CHANGE_ID' , value : ' ' }
63
65
environment name : ' CHANGE_TARGET' , value : ' develop'
64
- environment name : ' SKIP_TESTS' , value : ' '
65
66
}
66
67
allOf {
67
68
environment name : ' CHANGE_ID' , value : ' '
68
69
anyOf {
69
70
not { changelog ' .*^Automated release [0-9\\ .]+$' }
70
71
branch ' master'
71
72
}
72
- environment name : ' SKIP_TESTS' , value : ' '
73
73
}
74
74
}
75
75
}
76
- stages {
77
- stage(' Build test image' ) {
78
- steps {
79
- checkout scm
80
- sh ''' docker build --pull --build-arg="VOLTO_VERSION=$VOLTO" --build-arg="ADDON_NAME=$NAMESPACE/$GIT_NAME" --build-arg="ADDON_PATH=$GIT_NAME" . -t $IMAGE_NAME-frontend'''
76
+ parallel {
77
+
78
+ stage(' Volto 17' ) {
79
+ agent { node { label ' docker-1.13' } }
80
+ stages {
81
+ stage(' Build test image' ) {
82
+ steps {
83
+ sh ''' docker build --pull --build-arg="VOLTO_VERSION=$VOLTO" --build-arg="ADDON_NAME=$NAMESPACE/$GIT_NAME" --build-arg="ADDON_PATH=$GIT_NAME" . -t $IMAGE_NAME-frontend'''
84
+ }
81
85
}
82
- }
83
-
84
- stage(' Fix code' ) {
85
- when {
86
+
87
+ stage(' Fix code' ) {
88
+ when {
86
89
environment name : ' CHANGE_ID' , value : ' '
87
90
not { branch ' master' }
88
- }
89
- steps {
90
- script {
91
+ }
92
+ steps {
93
+ script {
91
94
fix_result = sh(script : ''' docker run --name="$IMAGE_NAME-fix" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend ci-fix''' , returnStatus : true )
92
95
sh ''' docker cp $IMAGE_NAME-fix:/app/src/addons/$GIT_NAME/src .'''
93
96
sh ''' docker rm -v $IMAGE_NAME-fix'''
@@ -105,31 +108,31 @@ pipeline {
105
108
sh ''' exit 1'''
106
109
}
107
110
}
111
+ }
108
112
}
109
- }
110
113
111
- stage(' ES lint' ) {
112
- steps {
113
- sh ''' docker run --rm --name="$IMAGE_NAME-eslint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend lint'''
114
+ stage(' ES lint' ) {
115
+ when { environment name : ' SKIP_TESTS' , value : ' ' }
116
+ steps {
117
+ sh ''' docker run --rm --name="$IMAGE_NAME-eslint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend lint'''
118
+ }
114
119
}
115
- }
116
120
117
- stage(' Style lint' ) {
118
- steps {
119
- sh ''' docker run --rm --name="$IMAGE_NAME-stylelint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend stylelint'''
121
+ stage(' Style lint' ) {
122
+ when { environment name : ' SKIP_TESTS' , value : ' ' }
123
+ steps {
124
+ sh ''' docker run --rm --name="$IMAGE_NAME-stylelint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend stylelint'''
125
+ }
120
126
}
121
- }
122
127
123
- stage(' Prettier' ) {
124
- steps {
125
- sh ''' docker run --rm --name="$IMAGE_NAME-prettier" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend prettier'''
128
+ stage(' Prettier' ) {
129
+ when { environment name : ' SKIP_TESTS' , value : ' ' }
130
+ steps {
131
+ sh ''' docker run --rm --name="$IMAGE_NAME-prettier" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend prettier'''
132
+ }
126
133
}
127
- }
128
-
129
- stage(' Coverage Tests' ) {
130
- parallel {
131
-
132
- stage(' Unit tests' ) {
134
+ stage(' Unit tests' ) {
135
+ when { environment name : ' SKIP_TESTS' , value : ' ' }
133
136
steps {
134
137
script {
135
138
try {
@@ -155,9 +158,10 @@ pipeline {
155
158
}
156
159
}
157
160
}
158
- }
161
+ }
159
162
160
- stage(' Integration tests' ) {
163
+ stage(' Integration tests' ) {
164
+ when { environment name : ' SKIP_TESTS' , value : ' ' }
161
165
steps {
162
166
script {
163
167
try {
@@ -211,26 +215,19 @@ pipeline {
211
215
}
212
216
}
213
217
}
214
- }
215
218
}
216
- }
217
- }
218
- post {
219
- always {
220
- sh script : " docker rmi $IMAGE_NAME -frontend" , returnStatus : true
221
- }
222
- }
223
- }
224
219
225
220
stage(' Report to SonarQube' ) {
226
221
when {
227
222
anyOf {
228
223
allOf {
229
224
not { environment name : ' CHANGE_ID' , value : ' ' }
230
225
environment name : ' CHANGE_TARGET' , value : ' develop'
226
+ environment name : ' SKIP_TESTS' , value : ' '
231
227
}
232
228
allOf {
233
229
environment name : ' CHANGE_ID' , value : ' '
230
+ environment name : ' SKIP_TESTS' , value : ' '
234
231
anyOf {
235
232
allOf {
236
233
branch ' develop'
@@ -255,14 +252,107 @@ pipeline {
255
252
}
256
253
}
257
254
255
+
256
+ }
257
+ }
258
+
259
+ stage(' Volto 16' ) {
260
+ agent { node { label ' integration' } }
261
+ when {
262
+ environment name : ' SKIP_TESTS' , value : ' '
263
+ not { environment name : ' VOLTO16_BREAKING_CHANGES' , value : ' yes' }
264
+ }
265
+ stages {
266
+ stage(' Build test image' ) {
267
+ steps {
268
+ sh ''' docker build --pull --build-arg="VOLTO_VERSION=16" --build-arg="ADDON_NAME=$NAMESPACE/$GIT_NAME" --build-arg="ADDON_PATH=$GIT_NAME" . -t $IMAGE_NAME-frontend16'''
269
+ }
270
+ }
271
+
272
+ stage(' Unit tests Volto 16' ) {
273
+ steps {
274
+ script {
275
+ try {
276
+ sh ''' docker run --name="$IMAGE_NAME-volto16" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend16 test-ci'''
277
+ sh ''' rm -rf xunit-reports16'''
278
+ sh ''' mkdir -p xunit-reports16'''
279
+ sh ''' docker cp $IMAGE_NAME-volto16:/app/junit.xml xunit-reports16/'''
280
+ } finally {
281
+ catchError(buildResult : ' SUCCESS' , stageResult : ' SUCCESS' ) {
282
+ junit testResults : ' xunit-reports16/junit.xml' , allowEmptyResults : true
283
+ }
284
+ sh script : ''' docker rm -v $IMAGE_NAME-volto16''' , returnStatus : true
285
+ }
286
+ }
287
+ }
288
+ }
289
+
290
+ stage(' Integration tests Volto 16' ) {
291
+ steps {
292
+ script {
293
+ try {
294
+ sh ''' docker run --pull always --rm -d --name="$IMAGE_NAME-plone16" -e SITE="Plone" -e PROFILES="$BACKEND_PROFILES" -e ADDONS="$BACKEND_ADDONS" eeacms/plone-backend'''
295
+ sh ''' docker run -d --shm-size=4g --link $IMAGE_NAME-plone16:plone --name="$IMAGE_NAME-cypress16" -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend16 start-ci'''
296
+ frontend = sh script :''' docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress16 make check-ci''' , returnStatus : true
297
+ if ( frontend != 0 ) {
298
+ sh ''' docker logs $IMAGE_NAME-cypress16; exit 1'''
299
+ }
300
+ sh ''' timeout -s 9 1800 docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress16 make cypress-ci'''
301
+ } finally {
302
+ try {
303
+ if ( frontend == 0 ) {
304
+ sh ''' rm -rf cypress-videos16 cypress-results16 cypress-coverage16 cypress-screenshots16'''
305
+ sh ''' mkdir -p cypress-videos16 cypress-results16 cypress-coverage16 cypress-screenshots16'''
306
+ videos = sh script : ''' docker cp $IMAGE_NAME-cypress16:/app/src/addons/$GIT_NAME/cypress/videos cypress-videos16/''' , returnStatus : true
307
+ sh ''' docker cp $IMAGE_NAME-cypress16:/app/src/addons/$GIT_NAME/cypress/reports cypress-results16/'''
308
+ screenshots = sh script : ''' docker cp $IMAGE_NAME-cypress16:/app/src/addons/$GIT_NAME/cypress/screenshots cypress-screenshots16''' , returnStatus : true
309
+
310
+ archiveArtifacts artifacts : ' cypress-screenshots16/**' , fingerprint : true , allowEmptyArchive : true
311
+
312
+ if ( videos == 0 ) {
313
+ sh ''' for file in $(find cypress-results16 -name *.xml); do if [ $(grep -E 'failures="[1-9].*"' $file | wc -l) -eq 0 ]; then testname=$(grep -E 'file=.*failures="0"' $file | sed 's#.* file=".*\\ /\\ (.*\\ .[jsxt]\\ +\\ )" time.*#\\ 1#' ); rm -f cypress-videos16/videos/$testname.mp4; fi; done'''
314
+ archiveArtifacts artifacts : ' cypress-videos16/**/*.mp4' , fingerprint : true , allowEmptyArchive : true
315
+ }
316
+ }
317
+ } finally {
318
+ catchError(buildResult : ' SUCCESS' , stageResult : ' SUCCESS' ) {
319
+ junit testResults : ' cypress-results16/**/*.xml' , allowEmptyResults : true
320
+ }
321
+ catchError(buildResult : ' SUCCESS' , stageResult : ' SUCCESS' ) {
322
+ sh ''' docker logs $IMAGE_NAME-cypress16'''
323
+ }
324
+ sh script : " docker stop $IMAGE_NAME -cypress16" , returnStatus : true
325
+ sh script : " docker stop $IMAGE_NAME -plone16" , returnStatus : true
326
+ sh script : " docker rm -v $IMAGE_NAME -plone16" , returnStatus : true
327
+ sh script : " docker rm -v $IMAGE_NAME -cypress16" , returnStatus : true
328
+ }
329
+ }
330
+ }
331
+ }
332
+ }
333
+
334
+ }
335
+ }
336
+ }
337
+ post {
338
+ always {
339
+ sh script : " docker rmi $IMAGE_NAME -frontend" , returnStatus : true
340
+ sh script : " docker rmi $IMAGE_NAME -frontend16" , returnStatus : true
341
+ }
342
+ }
343
+ }
344
+
345
+
258
346
stage(' SonarQube compare to master' ) {
259
347
when {
260
348
anyOf {
261
349
allOf {
262
350
not { environment name : ' CHANGE_ID' , value : ' ' }
263
351
environment name : ' CHANGE_TARGET' , value : ' develop'
352
+ environment name : ' SKIP_TESTS' , value : ' '
264
353
}
265
354
allOf {
355
+ environment name : ' SKIP_TESTS' , value : ' '
266
356
environment name : ' CHANGE_ID' , value : ' '
267
357
branch ' develop'
268
358
not { changelog ' .*^Automated release [0-9\\ .]+$' }
@@ -323,3 +413,4 @@ pipeline {
323
413
}
324
414
}
325
415
}
416
+
0 commit comments