blob: 53fea55036d1488d702455aadfc583056ce5c62a [file] [log] [blame]
Minos Galanakisda546842018-10-10 17:03:36 +01001#!/usr/bin/env groovy
2
3/**
4* Copyright (c) 2018-2019 ARM Limited
5* SPDX-License-Identifier: BSD-3-Clause
6*
7* The following pipeline compiles, checks code-style and runs fastmodel
8* tests to each gerrit path on tracked branch (tfm master).
9*/
10
11/* Need to define a single status control variable for each stage */
12def checkout_nightlies_job_result = 'FAILURE'
13def checkout_tfm_job_result = 'FAILURE'
14def checkout_lava_runner_job_result = 'FAILURE'
15def checkout_ci_scripts_job_result = 'FAILURE'
16def cppcheck_job_result = 'FAILURE'
17def checkpath_job_result = 'FAILURE'
18def build_job_result = 'FAILURE'
Galanakis, Minosb96c6d42019-06-20 10:41:28 +010019def build_docs_result = 'FAILURE'
Minos Galanakisda546842018-10-10 17:03:36 +010020def artifact_job_result = 'FAILURE'
Galanakis, Minosb96c6d42019-06-20 10:41:28 +010021def fastmodel_job_result = 'FAILURE'
22def lava_job_result = 'FAILURE'
23def timeout_def_stage = 60
24def timeout_build_stage = 180
25def timeout_test_stage = 180
Minos Galanakisda546842018-10-10 17:03:36 +010026/* Variable to store the stage that failed */
27def failed_stage = ''
28
Galanakis, Minosb96c6d42019-06-20 10:41:28 +010029/* Define docker images used in pipeline */
30def docker_img_orchestrator = 'docker-amd64-xenial'
31def docker_img_builder = 'docker-amd64-xenial'
32
Minos Galanakisda546842018-10-10 17:03:36 +010033pipeline {
34 agent {
35 node {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +010036 label docker_img_orchestrator
Minos Galanakisda546842018-10-10 17:03:36 +010037 }
38 }
39 environment {
40
Galanakis, Minosb96c6d42019-06-20 10:41:28 +010041 /* Any paths added here be appened to ENV.PATH */
42 EXTRA_PATHS = ('')
43
Minos Galanakisda546842018-10-10 17:03:36 +010044 /* Trusted Firmware checkout directory */
45 TFM_DIR = "tf-m"
46
47 /* Trusted Firmware CI Script checkout directory */
Galanakis, Minosb96c6d42019-06-20 10:41:28 +010048 TFM_CI_SCR_DIR = "tfm-ci-scripts"
Minos Galanakisda546842018-10-10 17:03:36 +010049
50 /* Virtual Evnrioment for Python2/3 name */
Galanakis, Minosb96c6d42019-06-20 10:41:28 +010051 VENV_P2_NAME = "tfm-openci-python2-venv"
52 VENV_P3_NAME = "tfm-openci-python3-venv"
Minos Galanakisda546842018-10-10 17:03:36 +010053
54 /* Check-patch related intermediate text file */
Galanakis, Minosb96c6d42019-06-20 10:41:28 +010055 CKPATCH_DETAILS_FILE = "checkpatch_details.txt"
Minos Galanakisda546842018-10-10 17:03:36 +010056
57 /* Check-patch ouput log file */
Galanakis, Minosb96c6d42019-06-20 10:41:28 +010058 CKPATCH_SUMMARY_FILE = "checkpatch_summary.json"
Minos Galanakisda546842018-10-10 17:03:36 +010059
60 /* CPP-check ouput log file */
Galanakis, Minosb96c6d42019-06-20 10:41:28 +010061 CPPCHCK_SUMMARY_FILE = "cppchk_summary.json"
Minos Galanakisda546842018-10-10 17:03:36 +010062
Galanakis, Minosb96c6d42019-06-20 10:41:28 +010063 /* File that captures information about checked-out dependencies */
64 CI_SCRIPTS_INFO_FILE = "openci_scripts_git_info.json"
Minos Galanakisda546842018-10-10 17:03:36 +010065
66 /* Git information log file */
Galanakis, Minosb96c6d42019-06-20 10:41:28 +010067 GIT_INFO_FILE = "tfm_git_info.json"
68
69 /* Build Wrapper output log file */
70 BUILD_SUMMARY_FILE = "build_summary.json"
71
72 /* Fast model testing output log file */
73 FPV_SUMMARY_FILE = "fvp_test_summary.json"
Minos Galanakisda546842018-10-10 17:03:36 +010074
75 /* Intermediate lava job definition file (passed to lava dispatcher)*/
76 LAVA_TEST_DEFINITION = "arm_cm3ds_mps2_gcc_arm.yaml"
77
78 /* Filename for results file provided by LAVA after testing */
79 LAVA_JOB_RESULTS = "lava_job_results.yaml"
80
81 /* lava output log file */
Galanakis, Minosb96c6d42019-06-20 10:41:28 +010082 LAVA_SUMMARY_FILE = "lava_summary.json"
Minos Galanakisda546842018-10-10 17:03:36 +010083
Galanakis, Minosb96c6d42019-06-20 10:41:28 +010084 /* Time the dispatcher will wait before cancelling a job */
85 LAVA_DISPATCHER_TIMEOUT_MINS = timeout_test_stage.toString()
86
87 /* Fast model testing output log file */
88 JENKINS_ENV_INFO_FILE = "jenviroment.json"
89
90 /* Directory where build artifacts are stored */
Minos Galanakisda546842018-10-10 17:03:36 +010091 BUILD_LOCATION = "build-ci-all"
92
Galanakis, Minosb96c6d42019-06-20 10:41:28 +010093 /* Directory where documententation is stored*/
94 BUILD_DOC_LOCATION = "build-docs"
95
96 /* Directory to store model test logs */
97 TEST_LOGS="model_tests_logs"
98
99 /* Pipeline specific directory references for internal use (stashing)*/
100 FPV_WORK_DIR="FVP_MPS2"
101 CMSIS_WORK_DIR="CMSIS_5"
102 MBEDTLS_WORK_DIR="mbedtls"
103 MBED_CRYPTO_WORK_DIR="mbed-crypto"
104 CHECKPATCH_WORK_DIR="checkpatch"
105
106 /* ARMLMD_LICENSE_FILE enviroment variable needs to be present
107 for ARMCLANG compiler. Ideally that is set from Jenkins ENV.
108 The product path depends on build-slave and should be set on
109 pipepline */
110 ARM_PRODUCT_PATH = '/home/buildslave/tools/sw/mappings'
111 ARM_TOOL_VARIANT = 'ult'
Minos Galanakisda546842018-10-10 17:03:36 +0100112 }
113 stages {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100114 stage('ci scripts') {
115 agent {
116 node {
117 label docker_img_builder
118 }
119 }
120 options {
121 timeout(time: timeout_def_stage, unit:'MINUTES')
122 }
123 steps {
124 script {
125 failed_stage = 'ci scripts'
126 }
127 checkout changelog: false, poll: false, scm: [
128 $class: 'GitSCM',
129 branches: [[name: '${GERRIT_SCRIPTS_REFSP}']],
130 doGenerateSubmoduleConfigurations: false,
131 extensions: [
132 [
133 $class: 'SubmoduleOption',
134 disableSubmodules: false,
135 parentCredentials: false,
136 recursiveSubmodules: true,
137 reference: '',
138 trackingSubmodules: false
139 ],
140 [
141 $class: 'CloneOption',
142 shallow: true
143 ],
144 [
145 $class:
146 'RelativeTargetDirectory',
147 relativeTargetDir:
148 "${TFM_CI_SCR_DIR}"
149 ]
150 ],
151 submoduleCfg: [],
152 userRemoteConfigs: [[
153 url: ("${GERRIT_URL}/"
154 + "${GERRIT_SCRIPTS}"),
155 refspec: ("refs/changes/*:"
156 + "refs/changes/*")
157 ]]
158 ]
159
160 /* Clean-up evnironment before stashing */
161 sh '''#!/bin/bash
162 set -e
163 # Capture the git information
164 python3 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
165 --collect --git-info ${TFM_CI_SCR_DIR} \\
166 --output-file ${CI_SCRIPTS_INFO_FILE}
167 '''.stripIndent()
168
169 /* Stash the CI Scripts */
170 stash includes: "${TFM_CI_SCR_DIR}/**/*", name: 'ci-scripts'
171 stash includes: "${CI_SCRIPTS_INFO_FILE}",
172 name: 'ci_scripts_git_info'
173 /* Always finish by setting the stage as SUCCESS */
174 script {
175 checkout_ci_scripts_job_result = 'SUCCESS'
176 failed_stage = ''
177 }
178 } /* steps */
179 post {
180 always {
181 echo "POST: ci scripts"
182 cleanWs()
183 } /* always */
184 } /* post */
185 } /* stage */
186 stage('Dependencies Checkout') {
Minos Galanakisda546842018-10-10 17:03:36 +0100187 parallel {
188 stage('Github (Nightlies)') {
189 agent {
190 node {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100191 label docker_img_builder
Minos Galanakisda546842018-10-10 17:03:36 +0100192 }
193 }
194 options {
195 timeout(time: timeout_def_stage, unit:'MINUTES')
196 }
197 steps {
198 script {
199 failed_stage = 'Github (Nightlies)'
200 }
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100201 /* Unstash the components from previous stages */
202 unstash 'ci-scripts'
203
204 /* Retrieve and extract artifacts from Nightly Job */
205 copyArtifacts projectName: "${REF_DEP_CHECKOUT_NAME}"
206 unzip zipFile: "${DEPENDENCIES_ARCHIVE_NAME_ZIP}",
Minos Galanakisda546842018-10-10 17:03:36 +0100207 quiet: true
208
Minos Galanakisda546842018-10-10 17:03:36 +0100209 sh '''#!/bin/bash
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100210 set -e
211 # Sanity check. Fail if data is untagged
212 if [ ! -f ${DEPENDENCIES_CONTENTS_FILE} ]; then
213 echo "Missing ${DEPENDENCIES_CONTENTS_FILE}, \\
214 please check nightly checkout job."
215 exit 1
216 else
217 echo "Parsing dependencies"
218 CMSIS_DIR=$(cat ${DEPENDENCIES_CONTENTS_FILE} | \\
219 jq -r ".[\\"cmsis\\"]\\
220 [\\"${DEPENDENCIES_CMSIS_TAG}\\"][\\"dir\\"]")
221 MBEDTLS_DIR=$(cat ${DEPENDENCIES_CONTENTS_FILE} | \\
222 jq -r ".[\\"mbedtls\\"]\\
223 [\\"${DEPENDENCIES_MBEDTLS_TAG}\\"][\\"dir\\"]")
Minos Galanakisda546842018-10-10 17:03:36 +0100224
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100225 MBEDTLS_CRYPTO_DIR=$(cat ${DEPENDENCIES_CONTENTS_FILE} \\
226 | jq -r ".[\\"mbedcrypto\\"]\\
227 [\\"${DEPENDENCIES_MBED_CRYPTO_TAG}\\"][\\"dir\\"]")
228 CHECKPATH_DIR=$(cat ${DEPENDENCIES_CONTENTS_FILE} \\
229 | jq -r ".[\\"checkpatch\\"]\\
230 [\\"${DEPENDENCIES_CHECKPATCH_TAG}\\"][\\"dir\\"]")
231
Minos Galanakisda546842018-10-10 17:03:36 +0100232 fi
Galanakis, Minos3e94feb2019-05-21 11:41:35 +0100233
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100234 # Check that provided input tags exist
235
236 # Create a labeled array for user selections
237 USER_TAG_LIST=(CHECKPATCH:"${DEPENDENCIES_CHECKPATCH_TAG}" \\
238 MBED_CRYPTO:"${DEPENDENCIES_MBED_CRYPTO_TAG}" \\
239 MBED_TLS:"${DEPENDENCIES_MBEDTLS_TAG}" \\
240 CMSIS:"${DEPENDENCIES_CMSIS_TAG}")
241
242 # Get extracted data from DEPENDENCIES_CONTENTS_FILE.
243 USER_SEL_LIST="$CHECKPATH_DIR $MBEDTLS_CRYPTO_DIR"
244 USER_SEL_LIST="$USER_SEL_LIST $MBEDTLS_DIR $CMSIS_DIR"
245 IFS=' ' read -ra USR_SEL_LIST <<< "${USER_SEL_LIST}"
246
247 TAG_COUNTER=0
248 # Look for data not found in contents (jq out -> null)
249 for USR_SEL in "${USR_SEL_LIST[@]}"; do
250 echo "$USR_SEL > $TAG_COUNTER"
251 if [ "$USR_SEL" == "null" ]; then
252
253 echo "Dependencies ERROR. "\\
254 "TAG: '${USER_TAG_LIST[TAG_COUNTER]}' "\\
255 "does not exist in checkout job."
256 exit 1
257 fi
258 ((TAG_COUNTER+=1))
259 done
260
261 # FIX for Jenkins unzip clearing permissions
262 chmod +x $CHECKPATH_DIR/checkpatch.pl
263
264 # Move the checked-out data to user-set directories
265 mv $CMSIS_DIR $CMSIS_WORK_DIR
266
267 # When the directory name from nightlies matches with
268 # the expected work dir, non selected entries must be
269 #removed
270 mv $MBEDTLS_DIR mbedtls_tmp && rm -rf mbedtls
271 mv $MBEDTLS_CRYPTO_DIR mbedcrypto_tmp
272 rm -rf mbed-crypto
273 mv $CHECKPATH_DIR checkpatch_tmp && rm -rf checkpatch
274 mv checkpatch_tmp $CHECKPATCH_WORK_DIR
275 mv mbedtls_tmp $MBEDTLS_WORK_DIR
276 mv mbedcrypto_tmp $MBED_CRYPTO_WORK_DIR
277
278
279 CONTENTS="cmsis=${DEPENDENCIES_CMSIS_TAG} \\
280 mbedtls=${DEPENDENCIES_MBEDTLS_TAG} \\
281 mbedcrypto=${DEPENDENCIES_MBED_CRYPTO_TAG} \\
282 checkpatch=${DEPENDENCIES_CHECKPATCH_TAG}" \\
283
284 if [ "${LAVA_TEST}" == "Enable" ]; then
285 echo "Fetching LAVA Dependancies"
286 # Prepare the FPGA image files
287 # Remove whitespace between commas
288 FPGA_IMAGES_TAG_LIST=$(echo ${FPGA_IMAGES_TAG_LIST} \\
289 | sed 's/[[:space:]]*,[[:space:]]*/,/g')
290 # Split the string using the comma.
291 IFS=',' read -ra FPGA_IMAGES <<< \\
292 "${FPGA_IMAGES_TAG_LIST}"
293
294 # Download each commit tag
295 for FPGA_NAME in "${FPGA_IMAGES[@]}"; do
296 # Strip whitespace
297 FPGA_NAME=$(echo $FPGA_NAME | xargs)
298
299 FPGA_IMAGE_F=$(cat \\
300 ${DEPENDENCIES_CONTENTS_FILE} | \\
301 jq -r ".[\\"fpga\\"]\\
302 [\\"${FPGA_NAME}\\"][\\"recovery\\"]")
303
304 if [ "$FPGA_IMAGE_F" == "null" ]; then
305 echo "Dependencies ERROR. "\\
306 "FPGA TAG: '${FPGA_NAME}' does not "\\
307 "exist in checkout job."
308 exit 1
309 else
310 echo "Proccessing FPGA Image: ${FPGA_IMAGE_F}"
311 cp ${FPGA_IMAGE_F} ./
312 fi
313 done
314 CONTENTS="${CONTENTS} fpga=${FPGA_IMAGES_TAG_LIST}"
Galanakis, Minos3e94feb2019-05-21 11:41:35 +0100315 fi
316
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100317 if [ "${FASTMODEL_TEST}" == "Enable" ]; then
318 echo "Fetching Fastmodel Dependancies"
319 # Copy the selected Fastmodel directory
320 FPV_DIR=$(cat ${DEPENDENCIES_CONTENTS_FILE} | \\
321 jq -r ".[\\"fastmodel\\"]\\
322 [\\"${DEPENDENCIES_FPV_TAG}\\"][\\"dir\\"]")
323
324 if [ "$FPV_DIR" == "null" ]; then
325 echo "Dependencies ERROR. "\\
326 "FASTMODEL TAG: '${DEPENDENCIES_FPV_TAG}'" \\
327 "does not exist in checkout job."
328 exit 1
329 fi
330 # FIX for Jenkins unzip clearing permissions
331 chmod +x $FPV_DIR/FVP_MPS2_AEMv8M
332
333 mv $FPV_DIR $FPV_WORK_DIR
334
335 # Store the user selection to report
336 CONTENTS="${CONTENTS} fastmodel=${DEPENDENCIES_FPV_TAG}"
337 fi
338
339 # Create a summary of the parameter provided versions
340 python3 \\
341 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
342 --report ${DEPENDENCIES_CONTENTS_FILE} \\
343 --filter-report ${CONTENTS} \\
344 --output-file ${DEPENDENCIES_CONTENTS_FILE}
345 '''.stripIndent()
346
347 stash includes: "${CMSIS_WORK_DIR}/**/*",
348 name: 'cmsis'
349
Minos Galanakisda546842018-10-10 17:03:36 +0100350 stash includes:
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100351 "${CHECKPATCH_WORK_DIR}/**/*",
352 name: 'checkpatch'
353
354 stash includes:
355 "${MBEDTLS_WORK_DIR}/**/*",
356 name: 'mbedtls'
357
358 stash includes:
359 "${MBED_CRYPTO_WORK_DIR}/**/*",
360 name: 'mbedcrypto'
361
362 stash includes:
363 "${DEPENDENCIES_CONTENTS_FILE}",
Minos Galanakisda546842018-10-10 17:03:36 +0100364 name: 'nightlies_info'
365
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100366 script {
367 if (params.FASTMODEL_TEST.equals('Enable')) {
368 stash includes: "${FPV_WORK_DIR}/**/*",
369 name: 'fvp_binaries'
370 }
371 if (params.LAVA_TEST.equals('Enable')) {
372 archiveArtifacts artifacts:
373 "*.tar.gz",
374 onlyIfSuccessful: false
375 }
376 } /* script */
377
Minos Galanakisda546842018-10-10 17:03:36 +0100378 /* Always finish by setting the stage as SUCCESS */
379 script {
380 checkout_nightlies_job_result = 'SUCCESS'
381 failed_stage = ''
382 }
383
384 } /* steps */
385 post {
386 always {
387 echo "POST: Github (Nightlies)"
388 cleanWs()
389 } /* always */
390 } /* post */
391 } /* stage */
392
393 stage('tf-m') {
394 agent {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100395 node {
396 label docker_img_builder
397 }
Minos Galanakisda546842018-10-10 17:03:36 +0100398 }
399 options {
400 timeout(time: timeout_def_stage, unit:'MINUTES')
401 }
402 steps {
403 script {
404 failed_stage = 'Checkout Trusted Firmware-M'
405 }
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100406 /* Unstash the components from previous stages */
407 unstash 'ci-scripts'
408
Minos Galanakisda546842018-10-10 17:03:36 +0100409 checkout changelog: true, poll: false, scm: [
410 $class: 'GitSCM',
411 branches: [[name: '${GERRIT_REFSPEC}']],
412 doGenerateSubmoduleConfigurations: false,
413 extensions: [
414 [
415 $class: 'SubmoduleOption',
416 disableSubmodules: false,
417 parentCredentials: false,
418 recursiveSubmodules: true,
419 reference: '',
420 trackingSubmodules: false
421 ],
422 [
423 $class: 'RelativeTargetDirectory',
424 relativeTargetDir: "${TFM_DIR}"
425 ]
426 ],
427 submoduleCfg: [],
428 userRemoteConfigs: [[
429 url: ("${GERRIT_URL}/"
430 + "${GERRIT_PROJECT}"),
431 refspec: ("refs/changes/*:"
432 + "refs/changes/*")
433 ]]
434 ]
435 sh '''#!/bin/bash
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100436 set -e
437 # Capture the git information
438 python3 \\
439 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
440 --collect --git-info ${TFM_DIR} \\
441 --output-file ${GIT_INFO_FILE}
Minos Galanakisda546842018-10-10 17:03:36 +0100442
443 cat ${GIT_INFO_FILE}
444 '''.stripIndent()
445
446 stash useDefaultExcludes: false, name: "${TFM_DIR}"
447 stash includes: ("${GIT_INFO_FILE}"), name: 'git_info'
448
449 /* Always finish by setting the stage as SUCCESS */
450 script {
451 checkout_tfm_job_result = 'SUCCESS'
452 failed_stage = ''
453 }
454 } /* steps */
455 post {
456 always {
457 echo "POST: Checkout Trusted Firmware-M"
458 cleanWs()
459 } /* always */
460 } /* post */
461
462 } /* stage */
Minos Galanakisda546842018-10-10 17:03:36 +0100463
Minos Galanakisda546842018-10-10 17:03:36 +0100464 } /* parallel */
465 } /* stage */
466
467 stage('Static Code Analysis') {
468 parallel {
469 stage('Cppcheck') {
470 agent {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100471 node {
472 label docker_img_builder
473 }
Minos Galanakisda546842018-10-10 17:03:36 +0100474 }
475 options {
476 timeout(time: timeout_def_stage, unit:'MINUTES')
477 }
478 steps {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100479 /* Unstash the components from previous stages */
Minos Galanakisda546842018-10-10 17:03:36 +0100480 unstash 'ci-scripts'
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100481 unstash 'cmsis'
482 unstash 'mbedtls'
483 unstash 'mbedcrypto'
484 unstash 'tf-m'
Minos Galanakisda546842018-10-10 17:03:36 +0100485
486 /* Run cppcheck */
487 sh '''#!/bin/bash
488 set -e
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100489 export PATH=$EXTRA_PATHS:$PATH
Minos Galanakisda546842018-10-10 17:03:36 +0100490
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100491 # Run cpp-check
492 pushd ${TFM_DIR}
493 if [ -n "${GERRIT_PATCHSET_REVISION}" ]; then
494 # Run CppCheck againist files modified
495 echo CppCheck againist Change-set
496 ../${TFM_CI_SCR_DIR}/run-cppcheck.sh HEAD
497 else
498 # Run CppCheck againist the full code-base
499 echo CppCheck againist base
500 ../${TFM_CI_SCR_DIR}/run-cppcheck.sh
501 fi
502 popd
Minos Galanakisda546842018-10-10 17:03:36 +0100503
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100504 # Parse the output into a report
505 python3 \\
506 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py\\
507 --collect --cpp-check-xml \\
508 ${TFM_DIR}/build-cppcheck/chk-config.xml \\
509 ${TFM_DIR}/build-cppcheck/chk-src.xml \\
510 --output-file ${CPPCHCK_SUMMARY_FILE}
511
512 head -n -2 ${TFM_DIR}/build-cppcheck/chk-config.xml \\
513 > cpp-join.xml
514 tail -n +5 ${TFM_DIR}/build-cppcheck/chk-src.xml \\
515 >> cpp-join.xml
Minos Galanakisda546842018-10-10 17:03:36 +0100516
517 #Create HTML report
518 cppcheck-htmlreport --source-encoding="iso8859-1" \\
519 --title="TFM Cppcheck Report" --source-dir=./ \\
520 --report-dir=./build-cppcheck-htmlreport/ \\
521 --file=./cpp-join.xml
Minos Galanakisda546842018-10-10 17:03:36 +0100522 '''.stripIndent()
523
524 stash includes:
525 ("${CPPCHCK_SUMMARY_FILE},"
526 + "${TFM_DIR}/build-cppcheck/chk-config.xml,"
527 + "${TFM_DIR}/build-cppcheck/chk-src.xml"),
528 name: 'cppcheck_summary'
529
530 /* Archive reports */
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100531 zip dir: "build-cppcheck-htmlreport",
Minos Galanakisda546842018-10-10 17:03:36 +0100532 zipFile: 'cppcheck-htmlreport.zip',
533 archive: true
534
535 archiveArtifacts artifacts:
536 "${CPPCHCK_SUMMARY_FILE}",
537 onlyIfSuccessful: false
538
539 sh '''#!/bin/bash
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100540 set -e
541 # Do not exit pipeline if erros are detected. Generate
542 # a trigger file which will notify user
543 CPPCHECK_EVAL=$(python3 \\
544 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
545 --all-fields-must-pass \\
546 --set-success-field 'success = True' \\
547 --report ${CPPCHCK_SUMMARY_FILE} \\
548 | tail -n 1)
Minos Galanakisda546842018-10-10 17:03:36 +0100549
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100550 if [ "$CPPCHECK_EVAL" == "Evaluation failed" ]; then
551 echo "Cppcheck analysis FAILED"
552 touch cppcheck.eval_failed
Minos Galanakisda546842018-10-10 17:03:36 +0100553 fi
554 '''.stripIndent()
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100555
556 /* Send email if */
557 script {
558 if (fileExists('cppcheck.eval_failed')) {
559 if (env.GERRIT_PATCHSET_UPLOADER_EMAIL) {
560 emailext (
561 subject: ("Job '${env.JOB_NAME}'build "
562 + "${env.BUILD_NUMBER} has "
563 + "failed Cppcheck check."),
564 body: ("Gerrit Change: "
565 + "${env.GERRIT_CHANGE_URL}.\n"
566 + "Please Check console output "
567 + " at: ${env.BUILD_URL}\nor "
568 + "summary report at: "
569 + "${env.BUILD_URL}/artifact/"
570 + "${CPPCHCK_SUMMARY_FILE}"),
571 to: "${env.GERRIT_PATCHSET_UPLOADER_EMAIL}",
572 )
573 }
574 }
575 } /* script */
Minos Galanakisda546842018-10-10 17:03:36 +0100576 /* Always finish by setting the stage as SUCCESS */
577 script {
578 cppcheck_job_result = 'SUCCESS'
579 failed_stage = ''
580 }
581 } /* steps */
582 post {
583 always {
584 echo "POST: Cppcheck"
585 cleanWs()
586 } /* always */
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100587 failure {
588 script {
589 failed_stage = 'Cppcheck'
590 }
591 }
Minos Galanakisda546842018-10-10 17:03:36 +0100592 } /* post */
593 } /* stage */
594
595 stage('check-patch') {
596 agent {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100597 node {
598 label docker_img_builder
599 }
Minos Galanakisda546842018-10-10 17:03:36 +0100600 }
601 options {
602 timeout(time: timeout_def_stage, unit:'MINUTES')
603 }
604 steps {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100605
606 /* Unstash the components from previous stages */
Minos Galanakisda546842018-10-10 17:03:36 +0100607 unstash 'tf-m'
608 unstash 'ci-scripts'
609 unstash 'checkpatch'
610
611 //Run check-patch
612 sh '''#!/bin/bash
613 set -e
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100614 export PATH=$EXTRA_PATHS:$PATH
Minos Galanakisda546842018-10-10 17:03:36 +0100615
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100616 # Run checkpatch
617 pushd ${TFM_DIR}
618
619 if [ -n "${GERRIT_PATCHSET_REVISION}" ]; then
620 # Run Checkpatch againist files modified
621 echo Checkpatch againist change-set
622 ../${TFM_CI_SCR_DIR}/run-checkpatch.sh \\
623 -l 1 -f ../${CKPATCH_DETAILS_FILE} \\
624 -p ../${CHECKPATCH_WORK_DIR}
625 else
626 # Run Checkpatch againist the full code-base
627 echo Checkpatch againist base
628 ../${TFM_CI_SCR_DIR}/run-checkpatch.sh \\
629 -l 0 -f ../${CKPATCH_DETAILS_FILE} \\
630 -p ../${CHECKPATCH_WORK_DIR}
631 fi
632 popd
633
634 # Create the report
635 python3 \\
636 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
637 --collect \\
638 --checkpatch-parse-f ${CKPATCH_DETAILS_FILE} \\
639 --output-file ${CKPATCH_SUMMARY_FILE}
Minos Galanakisda546842018-10-10 17:03:36 +0100640 '''.stripIndent()
641
642 archiveArtifacts artifacts:
643 "${CKPATCH_SUMMARY_FILE}",
644 onlyIfSuccessful: false
645
646 stash includes:
647 "${CKPATCH_SUMMARY_FILE}",
648 name: 'checkpatch_summary'
649
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100650 sh '''#!/bin/bash
651 set -e
652 # Do not exit pipeline if erros are detected. Generate
653 # a trigger file which will notify user
654 CHECPATCH_EVAL=$(python3 \\
655 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
656 --all-fields-must-pass \\
657 --set-success-field 'success = True' \\
658 --report ${CKPATCH_SUMMARY_FILE} \\
659 | tail -n 1)
660
661 if [ "$CHECPATCH_EVAL" == "Evaluation failed" ]; then
662 echo "Checkpatch analysis FAILED"
663 touch checkpatch.eval_failed
664 fi
665 '''.stripIndent()
666
667 /* Send email if */
668 script {
669 if (fileExists('checkpatch.eval_failed')) {
670 if (env.GERRIT_PATCHSET_UPLOADER_EMAIL) {
671 emailext (
672 subject: ("Job '${env.JOB_NAME}'build "
673 + "${env.BUILD_NUMBER} has "
674 + "failed Checkpatch check."),
675 body: ("Gerrit Change: "
676 + "${env.GERRIT_CHANGE_URL}.\n"
677 + "Please Check console output "
678 + "at: ${env.BUILD_URL}\nor "
679 + "summary report at: "
680 + "${env.BUILD_URL}/artifact/"
681 + "${CKPATCH_SUMMARY_FILE}"),
682 to: "${env.GERRIT_PATCHSET_UPLOADER_EMAIL}",
683 )
684 }
685 }
686 } /* script */
687
Minos Galanakisda546842018-10-10 17:03:36 +0100688 /* Always finish by setting the stage as SUCCESS */
689 script {
690 checkpath_job_result = 'SUCCESS'
691 failed_stage = ''
692 }
693 } /* steps */
694 post {
695 always {
696 echo "POST: check-patch"
697 cleanWs()
698 } /* always */
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100699 failure {
700 script {
701 failed_stage = 'check-patch'
702 }
703 }
Minos Galanakisda546842018-10-10 17:03:36 +0100704 } /* post */
705 } /* stage */
706 } /* parallel */
707 } /* stage */
708
709 stage('Build') {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100710 parallel {
711 stage('Configurations') {
712 agent {
713 node {
714 label docker_img_builder
715 }
716 }
717 options {
718 timeout(time: timeout_build_stage, unit:'MINUTES')
719 }
720 steps {
721 script {
722 failed_stage = 'Build-Configurations'
723 }
724 /* Unstash the components from previous stages */
725 unstash 'mbedtls'
726 unstash 'mbedcrypto'
727 unstash 'cmsis'
728 unstash 'tf-m'
729 unstash 'ci-scripts'
Minos Galanakisda546842018-10-10 17:03:36 +0100730
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100731 //Run the build and generate a summary report file.
732 sh '''#!/bin/bash
733 set -e
734 export PATH=$EXTRA_PATHS:$PATH
Minos Galanakisda546842018-10-10 17:03:36 +0100735
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100736 # Use build info from config if avaibale.
737 if [ -n "${BUILD_CONFIG_JSON}" ]; then
738 echo "Overriding build config with user provided one"
739 echo ${BUILD_CONFIG_JSON} > build_config.json
740 B_CONFIG="-f build_config.json"
741 else
742 B_CONFIG="--config full --install"
743 fi
Minos Galanakisda546842018-10-10 17:03:36 +0100744
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100745 # Build the project combinations
746 python3 ${TFM_CI_SCR_DIR}/build_helper/build_helper.py \\
747 -b ${BUILD_LOCATION} -s -l \\
748 -p ${BUILD_PARALLEL_NO} -n ${BUILD_THREAD_NO} \\
749 -r ${BUILD_SUMMARY_FILE} ${B_CONFIG}
750 '''.stripIndent()
Minos Galanakisda546842018-10-10 17:03:36 +0100751
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100752 /* Archive artifacts before evaluating report. */
753 archiveArtifacts artifacts: ("${BUILD_LOCATION}/" +
754 "*_*_*_*_*/install/**/*"),
755 excludes: '**/*.map',
756 onlyIfSuccessful: true
Minos Galanakisda546842018-10-10 17:03:36 +0100757
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100758 /* Stash binaries to be used by nightly test jobs. */
759 stash includes: ("${BUILD_LOCATION}/*_*_*_*_*/" +
760 "install/outputs/**/*.*"),
761 name: 'build_binaries'
Minos Galanakisda546842018-10-10 17:03:36 +0100762
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100763 /* Stash summary to be used by upstream project. */
764 stash includes: "${BUILD_SUMMARY_FILE}",
765 name: 'build_summary'
766 archiveArtifacts artifacts: "${BUILD_SUMMARY_FILE}"
Minos Galanakisda546842018-10-10 17:03:36 +0100767
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100768 sh '''#!/bin/bash
769 set -e
770 # Parse the output report(exit(1) if build has failed)
771 python3 \\
772 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
773 --all-fields-must-pass --error_if_failed \\
774 --report ${BUILD_SUMMARY_FILE}
775 '''.stripIndent()
Minos Galanakisda546842018-10-10 17:03:36 +0100776
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100777 script {
778 build_job_result = 'SUCCESS'
779 failed_stage = ''
780 }
781 } /* steps */
782 post {
783 always {
784 echo "POST: Build"
785 /* Save build logs */
786 archiveArtifacts artifacts: "build-ci-all/*.log",
787 onlyIfSuccessful: false
788 cleanWs()
789 } /* always */
790 } /* post */
791 } /* stage */
Minos Galanakisda546842018-10-10 17:03:36 +0100792
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100793 stage('Documentation') {
794 agent {
795 node {
796 label docker_img_builder
797 }
798 }
799 options {
800 timeout(time: timeout_build_stage, unit:'MINUTES')
801 }
802 when {
803 allOf {
804 environment name: 'BUILD_DOCS', value: 'Enable'
805 }
806 }
807 steps {
808 script {
809 failed_stage = 'Build-Documentation'
810 }
811 /* Unstash the components from previous stages */
812 unstash 'mbedtls'
813 unstash 'mbedcrypto'
814 unstash 'cmsis'
815 unstash 'tf-m'
816 unstash 'ci-scripts'
Minos Galanakisda546842018-10-10 17:03:36 +0100817
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100818 //Run the build and generate a summary report file.
819 sh '''#!/bin/bash
820 set -e
821 export PATH=$EXTRA_PATHS:$PATH
822
823 # Build doncumentation
824 python3 \\
825 ${TFM_CI_SCR_DIR}/build_helper/build_helper.py \\
826 -b ${BUILD_DOC_LOCATION} -l --config doxygen
827 '''.stripIndent()
828
829 archiveArtifacts artifacts: ("${BUILD_DOC_LOCATION}/" +
830 "*/install/doc/**/*"),
831 onlyIfSuccessful: true
832
833 script {
834 build_docs_result = 'SUCCESS'
835 failed_stage = ''
836 }
837 } /* steps */
838 post {
839 always {
840 echo "POST: Build Documentation"
841 cleanWs()
842 } /* always */
843 } /* post */
844 } /* stage */
845
846 } /* parallel */
Minos Galanakisda546842018-10-10 17:03:36 +0100847 } /* stage */
Dean Arnold83f1af22019-05-15 20:58:03 +0100848
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100849 stage('Tests') {
850 parallel {
851 stage('Fastmodel') {
852 agent {
853 node {
854 label docker_img_builder
855 }
856 }
857 options {
858 timeout(time: 60, unit:'MINUTES')
859 }
860 when {
861 allOf {
862 environment name: 'FASTMODEL_TEST', value: 'Enable'
863 }
864 }
865 steps {
866 /* Unstash the components from previous stages */
867 unstash 'ci-scripts'
868 unstash 'fvp_binaries'
869 unstash 'build_binaries'
870 unstash 'build_summary'
Dean Arnold83f1af22019-05-15 20:58:03 +0100871
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100872 script {
873 failed_stage = 'Fast Model Testing'
874 }
875 sh '''#!/bin/bash
876 set -e
877 python3 -u \\
878 ${TFM_CI_SCR_DIR}/fastmodel_dispatcher/fastmodel_dispatcher.py \\
879 --build_report ${BUILD_SUMMARY_FILE} \\
880 --report ${FPV_SUMMARY_FILE}
Dean Arnold83f1af22019-05-15 20:58:03 +0100881
Dean Arnold83f1af22019-05-15 20:58:03 +0100882
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100883 # Filter out the test results
884 mkdir -p ${TEST_LOGS}
885 mv terminal*.log ${TEST_LOGS}/
886 '''.stripIndent()
Dean Arnold83f1af22019-05-15 20:58:03 +0100887
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100888 stash includes: "${FPV_SUMMARY_FILE}",
889 name: 'fastmodel_summary'
890 archiveArtifacts artifacts: "${FPV_SUMMARY_FILE}"
891 archiveArtifacts artifacts: "${TEST_LOGS}/*"
Dean Arnold83f1af22019-05-15 20:58:03 +0100892
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100893 sh '''#!/bin/bash
894 set -e
895 # Parse the report
896 python3 \\
897 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
898 --all-fields-must-pass --error_if_failed \\
899 --set-success-field 'success = True' \\
900 --report ${FPV_SUMMARY_FILE}
901 '''.stripIndent()
902 script {
903 fastmodel_job_result = 'SUCCESS'
904 failed_stage = ''
905 }
906 } /* steps */
907 post {
908 always {
909 echo "POST: Fastmodel Tests"
910 cleanWs()
911 } /* always */
912 } /* post */
913 } /* stage */
Dean Arnold83f1af22019-05-15 20:58:03 +0100914
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100915 stage('Lava') {
916 agent {
917 node {
918 label docker_img_builder
919 }
920 }
921 environment {
922 /* Authentication token coming from host */
923 LAVA_CREDENTIAL = credentials("${LAVA_CREDENTIAL_ID}")
Dean Arnold83f1af22019-05-15 20:58:03 +0100924
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100925 /* Helper function separates USR/PSW credentials. Asign
926 them to a more commonly used notation */
927 LAVA_USER="${LAVA_CREDENTIAL_USR}"
928 LAVA_TOKEN="${LAVA_CREDENTIAL_PSW}"
Dean Arnold83f1af22019-05-15 20:58:03 +0100929
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100930 }
931 options {
932 timeout(time: timeout_test_stage, unit:'MINUTES')
933 }
934 when {
935 allOf {
936 environment name: 'LAVA_TEST', value: 'Enable'
937 }
938 }
939 steps {
940 script {
941 failed_stage = 'Lava test'
942 }
943 unstash 'ci-scripts'
Dean Arnold83f1af22019-05-15 20:58:03 +0100944
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100945 sh '''#!/bin/bash
946 set -e
947 # If no conifig is provided use the built'in
948 if [ -n "${LAVA_TEST_CONFIG_JSON}" ]; then
949 echo "Overriding test config."
950 echo ${LAVA_TEST_CONFIG_JSON} > test_config.json
951 T_CONFIG="--config-file test_config.json"
952 fi
Dean Arnold83f1af22019-05-15 20:58:03 +0100953
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100954 # Generate the lava definition file
955 python3 -u \\
956 ./${TFM_CI_SCR_DIR}/lava_helper/lava_helper.py \\
957 --task-create-definition \\
958 --create-definition-build-no ${BUILD_NUMBER} \\
959 --override-jenkins-url ${JENKINS_URL} \\
960 --override-jenkins-job ${JOB_NAME} \\
961 --create-definition-output-file \\
962 "${LAVA_TEST_DEFINITION}" \\
963 ${T_CONFIG}
Dean Arnold83f1af22019-05-15 20:58:03 +0100964
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100965 # Do not submit invalid jobs
966 if [ ! -f "${LAVA_TEST_DEFINITION}" ]; then
967 echo "LAVA job file does not exist: ${JOB}"
968 exit -1
969 fi
Dean Arnold83f1af22019-05-15 20:58:03 +0100970
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100971 # Convert timeout to seconds
972 DTOUT=$((${LAVA_DISPATCHER_TIMEOUT_MINS} * 60))
Dean Arnold83f1af22019-05-15 20:58:03 +0100973
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100974 # Submit the job to LAVA
975 python3 -u \\
976 ./${TFM_CI_SCR_DIR}/lava_helper/lava_helper.py \\
977 --task-dispatch "$LAVA_TEST_DEFINITION" \\
978 --dispatch-timeout ${DTOUT} \\
979 --dispatch-lava-url ${LAVA_URL} \\
980 --dispatch-lava-job-results-file \\
981 ${LAVA_JOB_RESULTS} \\
982 --dispatch-lava_token_from_environ
Dean Arnold83f1af22019-05-15 20:58:03 +0100983
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100984 # If tokens are not provided withCredentials bidnings
985 # they can be manually set by:
986 # --dispatch-lava_token_usr
987 # --dispatch-lava_token_secret
Dean Arnold83f1af22019-05-15 20:58:03 +0100988
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100989 # Verify the results and store them into a summary
990 python3 \\
991 ./${TFM_CI_SCR_DIR}/lava_helper/lava_helper.py \\
992 --task-lava-parse ${LAVA_JOB_RESULTS} \\
993 --output-report "${LAVA_SUMMARY_FILE}"
994 '''.stripIndent()
995
996 archiveArtifacts artifacts:
997 "${LAVA_JOB_RESULTS}," +
998 "${LAVA_TEST_DEFINITION}," +
999 "${LAVA_SUMMARY_FILE}",
1000 onlyIfSuccessful: false
1001
1002 stash includes:
1003 ("${LAVA_SUMMARY_FILE},"
1004 + "${LAVA_JOB_RESULTS},"
1005 + "${LAVA_TEST_DEFINITION}"),
1006 name: 'lava_summary'
1007
1008 sh '''#!/bin/bash
1009 set -e
1010 # Parse the output report(exit(1) if build has failed)
1011 python3 \\
1012 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
1013 --all-fields-must-pass --error_if_failed \\
1014 --set-success-field 'success = True' \\
1015 --report ${LAVA_SUMMARY_FILE}
1016 '''.stripIndent()
1017
1018 script {
1019 lava_job_result = 'SUCCESS'
1020 failed_stage = ''
1021 }
1022 } /* steps */
1023 post {
1024 always {
1025 script {
1026 if (currentBuild.result == 'FAILURE') {
1027 sh '''#!/bin/bash
1028 # If no job has been submittied the file
1029 # will not exist
1030 if [ ! -f lava_job.id ]; then
1031 echo "No LAVA job pending"
1032 exit 0
1033 fi
1034
1035 # Send the request to cancell the job
1036 python3 -u \\
1037 ./${TFM_CI_SCR_DIR}/lava_helper/lava_helper.py \\
1038 --dispatch-lava-url ${LAVA_URL} \\
1039 --dispatch-cancel $(cat lava_job.id) \\
1040 --dispatch-lava_token_from_environ
1041 '''.stripIndent()
1042
1043 } else {
1044 echo "POST: Lava test passed"
1045 }
1046
1047 cleanWs()
1048 } /* script */
1049 } /* always */
1050 } /* post */
1051 } /* stage */
1052 } /* parallel */
1053 } /* stage */
1054
Minos Galanakisda546842018-10-10 17:03:36 +01001055 stage('Proccess Artifacts & Report') {
1056 agent {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +01001057 node {
1058 label docker_img_builder
1059 }
Minos Galanakisda546842018-10-10 17:03:36 +01001060 }
1061 options {
1062 timeout(time: timeout_def_stage, unit:'MINUTES')
1063 }
1064 steps {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +01001065 unstash 'ci_scripts_git_info'
1066 unstash 'nightlies_info'
1067 unstash 'git_info'
1068 unstash 'build_summary'
1069 unstash 'checkpatch_summary'
1070 unstash 'cppcheck_summary'
1071
Minos Galanakisda546842018-10-10 17:03:36 +01001072 script {
1073 failed_stage = 'Proccess Artifacts & Report'
Galanakis, Minosb96c6d42019-06-20 10:41:28 +01001074
1075 if (params.FASTMODEL_TEST.equals('Enable')) {
1076 unstash 'fastmodel_summary'
1077 }
1078 if (params.LAVA_TEST.equals('Enable')) {
1079 unstash 'lava_summary'
1080 }
1081 } /* script */
1082 //Create build result summary to be posted to gerrit.
1083 //Basically contactenate build summary got from downstream jobs
1084 //with a header inserted in between.
1085
1086 /* Unstash the components from previous stages */
1087 unstash 'ci-scripts'
1088
1089 sh '''#!/bin/bash
1090 set -e
1091 # Collect enviroment information
1092 python3 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
1093 --collect --jenkins-info \\
1094 --output-file ${JENKINS_ENV_INFO_FILE}
1095
1096 # Merge all the reports into a summary
1097 REPORT_LIST="cppcheck=${CPPCHCK_SUMMARY_FILE} \\
1098 checkpatch=${CKPATCH_SUMMARY_FILE} \\
1099 build=${BUILD_SUMMARY_FILE} \\
1100 tf-m=${GIT_INFO_FILE} \\
1101 ci-scripts=${CI_SCRIPTS_INFO_FILE} \\
1102 dependencies-info=${DEPENDENCIES_CONTENTS_FILE} \\
1103 jenkings-info=${JENKINS_ENV_INFO_FILE}"
1104
1105 if [ -f "${LAVA_SUMMARY_FILE}" ]; then
1106 REPORT_LIST="${REPORT_LIST} lava=${LAVA_SUMMARY_FILE}"
1107 fi
1108
1109 if [ -f "${FPV_SUMMARY_FILE}" ]; then
1110 REPORT_LIST="${REPORT_LIST} fastmodel=${FPV_SUMMARY_FILE}"
1111 fi
1112
1113 python3 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
1114 --collate-report $REPORT_LIST \\
1115 --output-file ${SUMMARY_FILE}
1116 '''.stripIndent()
1117
1118 /* Archive summary to make it avaibale later. */
1119 archiveArtifacts artifacts: "${SUMMARY_FILE}"
1120
1121 script {
1122 def test_pass = false
1123
Minos Galanakisda546842018-10-10 17:03:36 +01001124 if (cppcheck_job_result == "SUCCESS" && \
1125 checkpath_job_result == "SUCCESS" && \
Galanakis, Minosb96c6d42019-06-20 10:41:28 +01001126 build_job_result == "SUCCESS") {
1127
1128 /* If a test is enabled but failed, then build
1129 has failed */
1130 if (params.FASTMODEL_TEST.equals('Enable') && \
1131 fastmodel_job_result == "FAILURE") {
1132 echo "model testing failed"
1133 currentBuild.result = "FAILURE"
1134 }
1135 else if (params.LAVA_TEST.equals('Enable') && \
1136 lava_job_result == "FAILURE") {
1137 echo "LAVA testing failed"
1138 currentBuild.result = "FAILURE"
1139 }
1140 else {
1141 echo "All jobs have been successfull"
1142 }
Minos Galanakisda546842018-10-10 17:03:36 +01001143 } else {
1144 echo "One or more jobs have failed"
1145 echo "Cppcheck status:"
1146 echo cppcheck_job_result
1147 echo "Checkpatch status:"
1148 echo checkpath_job_result
1149 echo "Build status:"
1150 echo build_job_result
Galanakis, Minosb96c6d42019-06-20 10:41:28 +01001151 echo "Model Test status:"
1152 echo fastmodel_job_result
1153 echo "LAVA Test status:"
Dean Arnold83f1af22019-05-15 20:58:03 +01001154 echo lava_job_result
Minos Galanakisda546842018-10-10 17:03:36 +01001155 currentBuild.result = "FAILURE"
1156 }
Minos Galanakisda546842018-10-10 17:03:36 +01001157
Minos Galanakisda546842018-10-10 17:03:36 +01001158 artifact_job_result = 'SUCCESS'
1159 failed_stage = ''
1160 }
1161 } /* steps */
1162 post {
1163 always {
1164 echo "POST: Proccess Artifacts & Report"
1165 cleanWs()
1166 } /* always */
1167 } /* post */
1168 } /* stage */
1169 } /* stages */
1170 post {
1171 always {
1172 cleanWs()
1173 } /* always */
1174 failure {
1175 script {
1176 if (!(params.MAINTAINER_EMAIL.equals(''))) {
1177 emailext (
1178 subject: ("Job '${env.JOB_NAME}'build "
1179 + "${env.BUILD_NUMBER}, failed at stage: "
1180 + "'${failed_stage}'"),
1181 body: "Check console output at ${env.BUILD_URL}",
1182 to: '${MAINTAINER_EMAIL}',
1183 recipientProviders: [
1184 [$class: ('CulpritsRecipient'
1185 + 'Provider')],
1186 [$class: ('RequesterRecipient'
1187 + 'Provider')]
1188 ]
1189 )
1190 }
1191 } /* script */
1192 } /* failure */
1193 aborted {
1194 script {
1195 if (!(params.MAINTAINER_EMAIL.equals(''))) {
1196 emailext (
1197 subject: ("Job '${env.JOB_NAME}'build "
1198 + "${env.BUILD_NUMBER}, cancelled at stage: "
1199 + "'${failed_stage}'"),
1200 body: "Check console output at ${env.BUILD_URL}",
1201 to: '${MAINTAINER_EMAIL}',
1202 recipientProviders: [
1203 [$class: ('CulpritsRecipient'
1204 + 'Provider')],
1205 [$class: ('RequesterRecipient'
1206 + 'Provider')]
1207 ]
1208 )
1209 }
1210 } /* script */
1211 } /* failure */
1212 } /* post */
1213} /* pipeline */