blob: 6be1764878cd4b415d4e204cec42057200d7a1a2 [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"
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100102 MBED_CRYPTO_WORK_DIR="mbed-crypto"
103 CHECKPATCH_WORK_DIR="checkpatch"
104
105 /* ARMLMD_LICENSE_FILE enviroment variable needs to be present
106 for ARMCLANG compiler. Ideally that is set from Jenkins ENV.
107 The product path depends on build-slave and should be set on
108 pipepline */
109 ARM_PRODUCT_PATH = '/home/buildslave/tools/sw/mappings'
110 ARM_TOOL_VARIANT = 'ult'
Minos Galanakisda546842018-10-10 17:03:36 +0100111 }
112 stages {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100113 stage('ci scripts') {
114 agent {
115 node {
116 label docker_img_builder
117 }
118 }
119 options {
120 timeout(time: timeout_def_stage, unit:'MINUTES')
121 }
122 steps {
123 script {
124 failed_stage = 'ci scripts'
125 }
126 checkout changelog: false, poll: false, scm: [
127 $class: 'GitSCM',
128 branches: [[name: '${GERRIT_SCRIPTS_REFSP}']],
129 doGenerateSubmoduleConfigurations: false,
130 extensions: [
131 [
132 $class: 'SubmoduleOption',
133 disableSubmodules: false,
134 parentCredentials: false,
135 recursiveSubmodules: true,
136 reference: '',
137 trackingSubmodules: false
138 ],
139 [
140 $class: 'CloneOption',
141 shallow: true
142 ],
143 [
144 $class:
145 'RelativeTargetDirectory',
146 relativeTargetDir:
147 "${TFM_CI_SCR_DIR}"
148 ]
149 ],
150 submoduleCfg: [],
151 userRemoteConfigs: [[
152 url: ("${GERRIT_URL}/"
153 + "${GERRIT_SCRIPTS}"),
154 refspec: ("refs/changes/*:"
155 + "refs/changes/*")
156 ]]
157 ]
158
159 /* Clean-up evnironment before stashing */
160 sh '''#!/bin/bash
161 set -e
162 # Capture the git information
163 python3 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
164 --collect --git-info ${TFM_CI_SCR_DIR} \\
165 --output-file ${CI_SCRIPTS_INFO_FILE}
166 '''.stripIndent()
167
168 /* Stash the CI Scripts */
169 stash includes: "${TFM_CI_SCR_DIR}/**/*", name: 'ci-scripts'
170 stash includes: "${CI_SCRIPTS_INFO_FILE}",
171 name: 'ci_scripts_git_info'
172 /* Always finish by setting the stage as SUCCESS */
173 script {
174 checkout_ci_scripts_job_result = 'SUCCESS'
175 failed_stage = ''
176 }
177 } /* steps */
178 post {
179 always {
180 echo "POST: ci scripts"
181 cleanWs()
182 } /* always */
183 } /* post */
184 } /* stage */
185 stage('Dependencies Checkout') {
Minos Galanakisda546842018-10-10 17:03:36 +0100186 parallel {
187 stage('Github (Nightlies)') {
188 agent {
189 node {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100190 label docker_img_builder
Minos Galanakisda546842018-10-10 17:03:36 +0100191 }
192 }
193 options {
194 timeout(time: timeout_def_stage, unit:'MINUTES')
195 }
196 steps {
197 script {
198 failed_stage = 'Github (Nightlies)'
199 }
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100200 /* Unstash the components from previous stages */
201 unstash 'ci-scripts'
202
203 /* Retrieve and extract artifacts from Nightly Job */
204 copyArtifacts projectName: "${REF_DEP_CHECKOUT_NAME}"
205 unzip zipFile: "${DEPENDENCIES_ARCHIVE_NAME_ZIP}",
Minos Galanakisda546842018-10-10 17:03:36 +0100206 quiet: true
207
Minos Galanakisda546842018-10-10 17:03:36 +0100208 sh '''#!/bin/bash
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100209 set -e
210 # Sanity check. Fail if data is untagged
211 if [ ! -f ${DEPENDENCIES_CONTENTS_FILE} ]; then
212 echo "Missing ${DEPENDENCIES_CONTENTS_FILE}, \\
213 please check nightly checkout job."
214 exit 1
215 else
216 echo "Parsing dependencies"
217 CMSIS_DIR=$(cat ${DEPENDENCIES_CONTENTS_FILE} | \\
218 jq -r ".[\\"cmsis\\"]\\
219 [\\"${DEPENDENCIES_CMSIS_TAG}\\"][\\"dir\\"]")
Minos Galanakisda546842018-10-10 17:03:36 +0100220
Raef Colesd0258462019-12-02 16:56:47 +0100221 MBEDCRYPTO_DIR=$(cat ${DEPENDENCIES_CONTENTS_FILE} \\
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100222 | jq -r ".[\\"mbedcrypto\\"]\\
223 [\\"${DEPENDENCIES_MBED_CRYPTO_TAG}\\"][\\"dir\\"]")
224 CHECKPATH_DIR=$(cat ${DEPENDENCIES_CONTENTS_FILE} \\
225 | jq -r ".[\\"checkpatch\\"]\\
226 [\\"${DEPENDENCIES_CHECKPATCH_TAG}\\"][\\"dir\\"]")
227
Minos Galanakisda546842018-10-10 17:03:36 +0100228 fi
Galanakis, Minos3e94feb2019-05-21 11:41:35 +0100229
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100230 # Check that provided input tags exist
231
232 # Create a labeled array for user selections
233 USER_TAG_LIST=(CHECKPATCH:"${DEPENDENCIES_CHECKPATCH_TAG}" \\
234 MBED_CRYPTO:"${DEPENDENCIES_MBED_CRYPTO_TAG}" \\
235 MBED_TLS:"${DEPENDENCIES_MBEDTLS_TAG}" \\
236 CMSIS:"${DEPENDENCIES_CMSIS_TAG}")
237
238 # Get extracted data from DEPENDENCIES_CONTENTS_FILE.
239 USER_SEL_LIST="$CHECKPATH_DIR $MBEDTLS_CRYPTO_DIR"
240 USER_SEL_LIST="$USER_SEL_LIST $MBEDTLS_DIR $CMSIS_DIR"
241 IFS=' ' read -ra USR_SEL_LIST <<< "${USER_SEL_LIST}"
242
243 TAG_COUNTER=0
244 # Look for data not found in contents (jq out -> null)
245 for USR_SEL in "${USR_SEL_LIST[@]}"; do
246 echo "$USR_SEL > $TAG_COUNTER"
247 if [ "$USR_SEL" == "null" ]; then
248
249 echo "Dependencies ERROR. "\\
250 "TAG: '${USER_TAG_LIST[TAG_COUNTER]}' "\\
251 "does not exist in checkout job."
252 exit 1
253 fi
254 ((TAG_COUNTER+=1))
255 done
256
257 # FIX for Jenkins unzip clearing permissions
258 chmod +x $CHECKPATH_DIR/checkpatch.pl
259
260 # Move the checked-out data to user-set directories
261 mv $CMSIS_DIR $CMSIS_WORK_DIR
262
263 # When the directory name from nightlies matches with
264 # the expected work dir, non selected entries must be
265 #removed
Raef Colesd0258462019-12-02 16:56:47 +0100266 mv $MBEDCRYPTO_DIR mbedcrypto_tmp
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100267 rm -rf mbed-crypto
268 mv $CHECKPATH_DIR checkpatch_tmp && rm -rf checkpatch
269 mv checkpatch_tmp $CHECKPATCH_WORK_DIR
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100270 mv mbedcrypto_tmp $MBED_CRYPTO_WORK_DIR
271
272
273 CONTENTS="cmsis=${DEPENDENCIES_CMSIS_TAG} \\
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100274 mbedcrypto=${DEPENDENCIES_MBED_CRYPTO_TAG} \\
275 checkpatch=${DEPENDENCIES_CHECKPATCH_TAG}" \\
276
277 if [ "${LAVA_TEST}" == "Enable" ]; then
278 echo "Fetching LAVA Dependancies"
279 # Prepare the FPGA image files
280 # Remove whitespace between commas
281 FPGA_IMAGES_TAG_LIST=$(echo ${FPGA_IMAGES_TAG_LIST} \\
282 | sed 's/[[:space:]]*,[[:space:]]*/,/g')
283 # Split the string using the comma.
284 IFS=',' read -ra FPGA_IMAGES <<< \\
285 "${FPGA_IMAGES_TAG_LIST}"
286
287 # Download each commit tag
288 for FPGA_NAME in "${FPGA_IMAGES[@]}"; do
289 # Strip whitespace
290 FPGA_NAME=$(echo $FPGA_NAME | xargs)
291
292 FPGA_IMAGE_F=$(cat \\
293 ${DEPENDENCIES_CONTENTS_FILE} | \\
294 jq -r ".[\\"fpga\\"]\\
295 [\\"${FPGA_NAME}\\"][\\"recovery\\"]")
296
297 if [ "$FPGA_IMAGE_F" == "null" ]; then
298 echo "Dependencies ERROR. "\\
299 "FPGA TAG: '${FPGA_NAME}' does not "\\
300 "exist in checkout job."
301 exit 1
302 else
303 echo "Proccessing FPGA Image: ${FPGA_IMAGE_F}"
304 cp ${FPGA_IMAGE_F} ./
305 fi
306 done
307 CONTENTS="${CONTENTS} fpga=${FPGA_IMAGES_TAG_LIST}"
Galanakis, Minos3e94feb2019-05-21 11:41:35 +0100308 fi
309
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100310 if [ "${FASTMODEL_TEST}" == "Enable" ]; then
311 echo "Fetching Fastmodel Dependancies"
312 # Copy the selected Fastmodel directory
313 FPV_DIR=$(cat ${DEPENDENCIES_CONTENTS_FILE} | \\
314 jq -r ".[\\"fastmodel\\"]\\
315 [\\"${DEPENDENCIES_FPV_TAG}\\"][\\"dir\\"]")
316
317 if [ "$FPV_DIR" == "null" ]; then
318 echo "Dependencies ERROR. "\\
319 "FASTMODEL TAG: '${DEPENDENCIES_FPV_TAG}'" \\
320 "does not exist in checkout job."
321 exit 1
322 fi
323 # FIX for Jenkins unzip clearing permissions
324 chmod +x $FPV_DIR/FVP_MPS2_AEMv8M
325
326 mv $FPV_DIR $FPV_WORK_DIR
327
328 # Store the user selection to report
329 CONTENTS="${CONTENTS} fastmodel=${DEPENDENCIES_FPV_TAG}"
330 fi
331
332 # Create a summary of the parameter provided versions
333 python3 \\
334 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
335 --report ${DEPENDENCIES_CONTENTS_FILE} \\
336 --filter-report ${CONTENTS} \\
337 --output-file ${DEPENDENCIES_CONTENTS_FILE}
338 '''.stripIndent()
339
340 stash includes: "${CMSIS_WORK_DIR}/**/*",
341 name: 'cmsis'
342
Minos Galanakisda546842018-10-10 17:03:36 +0100343 stash includes:
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100344 "${CHECKPATCH_WORK_DIR}/**/*",
345 name: 'checkpatch'
346
347 stash includes:
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100348 "${MBED_CRYPTO_WORK_DIR}/**/*",
349 name: 'mbedcrypto'
350
351 stash includes:
352 "${DEPENDENCIES_CONTENTS_FILE}",
Minos Galanakisda546842018-10-10 17:03:36 +0100353 name: 'nightlies_info'
354
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100355 script {
356 if (params.FASTMODEL_TEST.equals('Enable')) {
357 stash includes: "${FPV_WORK_DIR}/**/*",
358 name: 'fvp_binaries'
359 }
360 if (params.LAVA_TEST.equals('Enable')) {
361 archiveArtifacts artifacts:
362 "*.tar.gz",
363 onlyIfSuccessful: false
364 }
365 } /* script */
366
Minos Galanakisda546842018-10-10 17:03:36 +0100367 /* Always finish by setting the stage as SUCCESS */
368 script {
369 checkout_nightlies_job_result = 'SUCCESS'
370 failed_stage = ''
371 }
372
373 } /* steps */
374 post {
375 always {
376 echo "POST: Github (Nightlies)"
377 cleanWs()
378 } /* always */
379 } /* post */
380 } /* stage */
381
382 stage('tf-m') {
383 agent {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100384 node {
385 label docker_img_builder
386 }
Minos Galanakisda546842018-10-10 17:03:36 +0100387 }
388 options {
389 timeout(time: timeout_def_stage, unit:'MINUTES')
390 }
391 steps {
392 script {
393 failed_stage = 'Checkout Trusted Firmware-M'
394 }
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100395 /* Unstash the components from previous stages */
396 unstash 'ci-scripts'
397
Minos Galanakisda546842018-10-10 17:03:36 +0100398 checkout changelog: true, poll: false, scm: [
399 $class: 'GitSCM',
400 branches: [[name: '${GERRIT_REFSPEC}']],
401 doGenerateSubmoduleConfigurations: false,
402 extensions: [
403 [
404 $class: 'SubmoduleOption',
405 disableSubmodules: false,
406 parentCredentials: false,
407 recursiveSubmodules: true,
408 reference: '',
409 trackingSubmodules: false
410 ],
411 [
412 $class: 'RelativeTargetDirectory',
413 relativeTargetDir: "${TFM_DIR}"
414 ]
415 ],
416 submoduleCfg: [],
417 userRemoteConfigs: [[
418 url: ("${GERRIT_URL}/"
419 + "${GERRIT_PROJECT}"),
420 refspec: ("refs/changes/*:"
421 + "refs/changes/*")
422 ]]
423 ]
424 sh '''#!/bin/bash
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100425 set -e
426 # Capture the git information
427 python3 \\
428 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
429 --collect --git-info ${TFM_DIR} \\
430 --output-file ${GIT_INFO_FILE}
Minos Galanakisda546842018-10-10 17:03:36 +0100431
432 cat ${GIT_INFO_FILE}
433 '''.stripIndent()
434
435 stash useDefaultExcludes: false, name: "${TFM_DIR}"
436 stash includes: ("${GIT_INFO_FILE}"), name: 'git_info'
437
438 /* Always finish by setting the stage as SUCCESS */
439 script {
440 checkout_tfm_job_result = 'SUCCESS'
441 failed_stage = ''
442 }
443 } /* steps */
444 post {
445 always {
446 echo "POST: Checkout Trusted Firmware-M"
447 cleanWs()
448 } /* always */
449 } /* post */
450
451 } /* stage */
Minos Galanakisda546842018-10-10 17:03:36 +0100452
Minos Galanakisda546842018-10-10 17:03:36 +0100453 } /* parallel */
454 } /* stage */
455
456 stage('Static Code Analysis') {
457 parallel {
458 stage('Cppcheck') {
459 agent {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100460 node {
461 label docker_img_builder
462 }
Minos Galanakisda546842018-10-10 17:03:36 +0100463 }
464 options {
465 timeout(time: timeout_def_stage, unit:'MINUTES')
466 }
467 steps {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100468 /* Unstash the components from previous stages */
Minos Galanakisda546842018-10-10 17:03:36 +0100469 unstash 'ci-scripts'
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100470 unstash 'cmsis'
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100471 unstash 'mbedcrypto'
472 unstash 'tf-m'
Minos Galanakisda546842018-10-10 17:03:36 +0100473
474 /* Run cppcheck */
475 sh '''#!/bin/bash
476 set -e
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100477 export PATH=$EXTRA_PATHS:$PATH
Minos Galanakisda546842018-10-10 17:03:36 +0100478
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100479 # Run cpp-check
480 pushd ${TFM_DIR}
481 if [ -n "${GERRIT_PATCHSET_REVISION}" ]; then
482 # Run CppCheck againist files modified
483 echo CppCheck againist Change-set
484 ../${TFM_CI_SCR_DIR}/run-cppcheck.sh HEAD
485 else
486 # Run CppCheck againist the full code-base
487 echo CppCheck againist base
488 ../${TFM_CI_SCR_DIR}/run-cppcheck.sh
489 fi
490 popd
Minos Galanakisda546842018-10-10 17:03:36 +0100491
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100492 # Parse the output into a report
493 python3 \\
494 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py\\
495 --collect --cpp-check-xml \\
496 ${TFM_DIR}/build-cppcheck/chk-config.xml \\
497 ${TFM_DIR}/build-cppcheck/chk-src.xml \\
498 --output-file ${CPPCHCK_SUMMARY_FILE}
499
500 head -n -2 ${TFM_DIR}/build-cppcheck/chk-config.xml \\
501 > cpp-join.xml
502 tail -n +5 ${TFM_DIR}/build-cppcheck/chk-src.xml \\
503 >> cpp-join.xml
Minos Galanakisda546842018-10-10 17:03:36 +0100504
505 #Create HTML report
506 cppcheck-htmlreport --source-encoding="iso8859-1" \\
507 --title="TFM Cppcheck Report" --source-dir=./ \\
508 --report-dir=./build-cppcheck-htmlreport/ \\
509 --file=./cpp-join.xml
Minos Galanakisda546842018-10-10 17:03:36 +0100510 '''.stripIndent()
511
512 stash includes:
513 ("${CPPCHCK_SUMMARY_FILE},"
514 + "${TFM_DIR}/build-cppcheck/chk-config.xml,"
515 + "${TFM_DIR}/build-cppcheck/chk-src.xml"),
516 name: 'cppcheck_summary'
517
518 /* Archive reports */
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100519 zip dir: "build-cppcheck-htmlreport",
Minos Galanakisda546842018-10-10 17:03:36 +0100520 zipFile: 'cppcheck-htmlreport.zip',
521 archive: true
522
523 archiveArtifacts artifacts:
524 "${CPPCHCK_SUMMARY_FILE}",
525 onlyIfSuccessful: false
526
527 sh '''#!/bin/bash
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100528 set -e
529 # Do not exit pipeline if erros are detected. Generate
530 # a trigger file which will notify user
531 CPPCHECK_EVAL=$(python3 \\
532 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
533 --all-fields-must-pass \\
534 --set-success-field 'success = True' \\
535 --report ${CPPCHCK_SUMMARY_FILE} \\
536 | tail -n 1)
Minos Galanakisda546842018-10-10 17:03:36 +0100537
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100538 if [ "$CPPCHECK_EVAL" == "Evaluation failed" ]; then
539 echo "Cppcheck analysis FAILED"
540 touch cppcheck.eval_failed
Minos Galanakisda546842018-10-10 17:03:36 +0100541 fi
542 '''.stripIndent()
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100543
544 /* Send email if */
545 script {
546 if (fileExists('cppcheck.eval_failed')) {
547 if (env.GERRIT_PATCHSET_UPLOADER_EMAIL) {
548 emailext (
549 subject: ("Job '${env.JOB_NAME}'build "
550 + "${env.BUILD_NUMBER} has "
551 + "failed Cppcheck check."),
552 body: ("Gerrit Change: "
553 + "${env.GERRIT_CHANGE_URL}.\n"
554 + "Please Check console output "
555 + " at: ${env.BUILD_URL}\nor "
556 + "summary report at: "
557 + "${env.BUILD_URL}/artifact/"
558 + "${CPPCHCK_SUMMARY_FILE}"),
559 to: "${env.GERRIT_PATCHSET_UPLOADER_EMAIL}",
560 )
561 }
562 }
563 } /* script */
Minos Galanakisda546842018-10-10 17:03:36 +0100564 /* Always finish by setting the stage as SUCCESS */
565 script {
566 cppcheck_job_result = 'SUCCESS'
567 failed_stage = ''
568 }
569 } /* steps */
570 post {
571 always {
572 echo "POST: Cppcheck"
573 cleanWs()
574 } /* always */
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100575 failure {
576 script {
577 failed_stage = 'Cppcheck'
578 }
579 }
Minos Galanakisda546842018-10-10 17:03:36 +0100580 } /* post */
581 } /* stage */
582
583 stage('check-patch') {
584 agent {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100585 node {
586 label docker_img_builder
587 }
Minos Galanakisda546842018-10-10 17:03:36 +0100588 }
589 options {
590 timeout(time: timeout_def_stage, unit:'MINUTES')
591 }
592 steps {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100593
594 /* Unstash the components from previous stages */
Minos Galanakisda546842018-10-10 17:03:36 +0100595 unstash 'tf-m'
596 unstash 'ci-scripts'
597 unstash 'checkpatch'
598
599 //Run check-patch
600 sh '''#!/bin/bash
601 set -e
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100602 export PATH=$EXTRA_PATHS:$PATH
Minos Galanakisda546842018-10-10 17:03:36 +0100603
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100604 # Run checkpatch
605 pushd ${TFM_DIR}
606
607 if [ -n "${GERRIT_PATCHSET_REVISION}" ]; then
608 # Run Checkpatch againist files modified
609 echo Checkpatch againist change-set
610 ../${TFM_CI_SCR_DIR}/run-checkpatch.sh \\
611 -l 1 -f ../${CKPATCH_DETAILS_FILE} \\
612 -p ../${CHECKPATCH_WORK_DIR}
613 else
614 # Run Checkpatch againist the full code-base
615 echo Checkpatch againist base
616 ../${TFM_CI_SCR_DIR}/run-checkpatch.sh \\
617 -l 0 -f ../${CKPATCH_DETAILS_FILE} \\
618 -p ../${CHECKPATCH_WORK_DIR}
619 fi
620 popd
621
622 # Create the report
623 python3 \\
624 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
625 --collect \\
626 --checkpatch-parse-f ${CKPATCH_DETAILS_FILE} \\
627 --output-file ${CKPATCH_SUMMARY_FILE}
Minos Galanakisda546842018-10-10 17:03:36 +0100628 '''.stripIndent()
629
630 archiveArtifacts artifacts:
631 "${CKPATCH_SUMMARY_FILE}",
632 onlyIfSuccessful: false
633
634 stash includes:
635 "${CKPATCH_SUMMARY_FILE}",
636 name: 'checkpatch_summary'
637
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100638 sh '''#!/bin/bash
639 set -e
640 # Do not exit pipeline if erros are detected. Generate
641 # a trigger file which will notify user
642 CHECPATCH_EVAL=$(python3 \\
643 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
644 --all-fields-must-pass \\
645 --set-success-field 'success = True' \\
646 --report ${CKPATCH_SUMMARY_FILE} \\
647 | tail -n 1)
648
649 if [ "$CHECPATCH_EVAL" == "Evaluation failed" ]; then
650 echo "Checkpatch analysis FAILED"
651 touch checkpatch.eval_failed
652 fi
653 '''.stripIndent()
654
655 /* Send email if */
656 script {
657 if (fileExists('checkpatch.eval_failed')) {
658 if (env.GERRIT_PATCHSET_UPLOADER_EMAIL) {
659 emailext (
660 subject: ("Job '${env.JOB_NAME}'build "
661 + "${env.BUILD_NUMBER} has "
662 + "failed Checkpatch check."),
663 body: ("Gerrit Change: "
664 + "${env.GERRIT_CHANGE_URL}.\n"
665 + "Please Check console output "
666 + "at: ${env.BUILD_URL}\nor "
667 + "summary report at: "
668 + "${env.BUILD_URL}/artifact/"
669 + "${CKPATCH_SUMMARY_FILE}"),
670 to: "${env.GERRIT_PATCHSET_UPLOADER_EMAIL}",
671 )
672 }
673 }
674 } /* script */
675
Minos Galanakisda546842018-10-10 17:03:36 +0100676 /* Always finish by setting the stage as SUCCESS */
677 script {
678 checkpath_job_result = 'SUCCESS'
679 failed_stage = ''
680 }
681 } /* steps */
682 post {
683 always {
684 echo "POST: check-patch"
685 cleanWs()
686 } /* always */
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100687 failure {
688 script {
689 failed_stage = 'check-patch'
690 }
691 }
Minos Galanakisda546842018-10-10 17:03:36 +0100692 } /* post */
693 } /* stage */
694 } /* parallel */
695 } /* stage */
696
697 stage('Build') {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100698 parallel {
699 stage('Configurations') {
700 agent {
701 node {
702 label docker_img_builder
703 }
704 }
705 options {
706 timeout(time: timeout_build_stage, unit:'MINUTES')
707 }
708 steps {
709 script {
710 failed_stage = 'Build-Configurations'
711 }
712 /* Unstash the components from previous stages */
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100713 unstash 'mbedcrypto'
714 unstash 'cmsis'
715 unstash 'tf-m'
716 unstash 'ci-scripts'
Minos Galanakisda546842018-10-10 17:03:36 +0100717
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100718 //Run the build and generate a summary report file.
719 sh '''#!/bin/bash
720 set -e
721 export PATH=$EXTRA_PATHS:$PATH
Minos Galanakisda546842018-10-10 17:03:36 +0100722
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100723 # Use build info from config if avaibale.
724 if [ -n "${BUILD_CONFIG_JSON}" ]; then
725 echo "Overriding build config with user provided one"
726 echo ${BUILD_CONFIG_JSON} > build_config.json
727 B_CONFIG="-f build_config.json"
728 else
729 B_CONFIG="--config full --install"
730 fi
Minos Galanakisda546842018-10-10 17:03:36 +0100731
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100732 # Build the project combinations
733 python3 ${TFM_CI_SCR_DIR}/build_helper/build_helper.py \\
734 -b ${BUILD_LOCATION} -s -l \\
735 -p ${BUILD_PARALLEL_NO} -n ${BUILD_THREAD_NO} \\
736 -r ${BUILD_SUMMARY_FILE} ${B_CONFIG}
737 '''.stripIndent()
Minos Galanakisda546842018-10-10 17:03:36 +0100738
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100739 /* Archive artifacts before evaluating report. */
740 archiveArtifacts artifacts: ("${BUILD_LOCATION}/" +
741 "*_*_*_*_*/install/**/*"),
742 excludes: '**/*.map',
743 onlyIfSuccessful: true
Minos Galanakisda546842018-10-10 17:03:36 +0100744
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100745 /* Stash binaries to be used by nightly test jobs. */
746 stash includes: ("${BUILD_LOCATION}/*_*_*_*_*/" +
747 "install/outputs/**/*.*"),
748 name: 'build_binaries'
Minos Galanakisda546842018-10-10 17:03:36 +0100749
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100750 /* Stash summary to be used by upstream project. */
751 stash includes: "${BUILD_SUMMARY_FILE}",
752 name: 'build_summary'
753 archiveArtifacts artifacts: "${BUILD_SUMMARY_FILE}"
Minos Galanakisda546842018-10-10 17:03:36 +0100754
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100755 sh '''#!/bin/bash
756 set -e
757 # Parse the output report(exit(1) if build has failed)
758 python3 \\
759 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
760 --all-fields-must-pass --error_if_failed \\
761 --report ${BUILD_SUMMARY_FILE}
762 '''.stripIndent()
Minos Galanakisda546842018-10-10 17:03:36 +0100763
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100764 script {
765 build_job_result = 'SUCCESS'
766 failed_stage = ''
767 }
768 } /* steps */
769 post {
770 always {
771 echo "POST: Build"
772 /* Save build logs */
773 archiveArtifacts artifacts: "build-ci-all/*.log",
774 onlyIfSuccessful: false
775 cleanWs()
776 } /* always */
777 } /* post */
778 } /* stage */
Minos Galanakisda546842018-10-10 17:03:36 +0100779
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100780 stage('Documentation') {
781 agent {
782 node {
783 label docker_img_builder
784 }
785 }
786 options {
787 timeout(time: timeout_build_stage, unit:'MINUTES')
788 }
789 when {
790 allOf {
791 environment name: 'BUILD_DOCS', value: 'Enable'
792 }
793 }
794 steps {
795 script {
796 failed_stage = 'Build-Documentation'
797 }
798 /* Unstash the components from previous stages */
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100799 unstash 'mbedcrypto'
800 unstash 'cmsis'
801 unstash 'tf-m'
802 unstash 'ci-scripts'
Minos Galanakisda546842018-10-10 17:03:36 +0100803
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100804 //Run the build and generate a summary report file.
805 sh '''#!/bin/bash
806 set -e
807 export PATH=$EXTRA_PATHS:$PATH
808
809 # Build doncumentation
810 python3 \\
811 ${TFM_CI_SCR_DIR}/build_helper/build_helper.py \\
812 -b ${BUILD_DOC_LOCATION} -l --config doxygen
813 '''.stripIndent()
814
815 archiveArtifacts artifacts: ("${BUILD_DOC_LOCATION}/" +
816 "*/install/doc/**/*"),
817 onlyIfSuccessful: true
818
819 script {
820 build_docs_result = 'SUCCESS'
821 failed_stage = ''
822 }
823 } /* steps */
824 post {
825 always {
826 echo "POST: Build Documentation"
827 cleanWs()
828 } /* always */
829 } /* post */
830 } /* stage */
831
832 } /* parallel */
Minos Galanakisda546842018-10-10 17:03:36 +0100833 } /* stage */
Dean Arnold83f1af22019-05-15 20:58:03 +0100834
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100835 stage('Tests') {
836 parallel {
837 stage('Fastmodel') {
838 agent {
839 node {
840 label docker_img_builder
841 }
842 }
843 options {
844 timeout(time: 60, unit:'MINUTES')
845 }
846 when {
847 allOf {
848 environment name: 'FASTMODEL_TEST', value: 'Enable'
849 }
850 }
851 steps {
852 /* Unstash the components from previous stages */
853 unstash 'ci-scripts'
854 unstash 'fvp_binaries'
855 unstash 'build_binaries'
856 unstash 'build_summary'
Dean Arnold83f1af22019-05-15 20:58:03 +0100857
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100858 script {
859 failed_stage = 'Fast Model Testing'
860 }
861 sh '''#!/bin/bash
862 set -e
863 python3 -u \\
864 ${TFM_CI_SCR_DIR}/fastmodel_dispatcher/fastmodel_dispatcher.py \\
865 --build_report ${BUILD_SUMMARY_FILE} \\
866 --report ${FPV_SUMMARY_FILE}
Dean Arnold83f1af22019-05-15 20:58:03 +0100867
Dean Arnold83f1af22019-05-15 20:58:03 +0100868
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100869 # Filter out the test results
870 mkdir -p ${TEST_LOGS}
871 mv terminal*.log ${TEST_LOGS}/
872 '''.stripIndent()
Dean Arnold83f1af22019-05-15 20:58:03 +0100873
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100874 stash includes: "${FPV_SUMMARY_FILE}",
875 name: 'fastmodel_summary'
876 archiveArtifacts artifacts: "${FPV_SUMMARY_FILE}"
877 archiveArtifacts artifacts: "${TEST_LOGS}/*"
Dean Arnold83f1af22019-05-15 20:58:03 +0100878
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100879 sh '''#!/bin/bash
880 set -e
881 # Parse the report
882 python3 \\
883 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
884 --all-fields-must-pass --error_if_failed \\
885 --set-success-field 'success = True' \\
886 --report ${FPV_SUMMARY_FILE}
887 '''.stripIndent()
888 script {
889 fastmodel_job_result = 'SUCCESS'
890 failed_stage = ''
891 }
892 } /* steps */
893 post {
894 always {
895 echo "POST: Fastmodel Tests"
896 cleanWs()
897 } /* always */
898 } /* post */
899 } /* stage */
Dean Arnold83f1af22019-05-15 20:58:03 +0100900
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100901 stage('Lava') {
902 agent {
903 node {
904 label docker_img_builder
905 }
906 }
907 environment {
908 /* Authentication token coming from host */
909 LAVA_CREDENTIAL = credentials("${LAVA_CREDENTIAL_ID}")
Dean Arnold83f1af22019-05-15 20:58:03 +0100910
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100911 /* Helper function separates USR/PSW credentials. Asign
912 them to a more commonly used notation */
913 LAVA_USER="${LAVA_CREDENTIAL_USR}"
914 LAVA_TOKEN="${LAVA_CREDENTIAL_PSW}"
Dean Arnold83f1af22019-05-15 20:58:03 +0100915
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100916 }
917 options {
918 timeout(time: timeout_test_stage, unit:'MINUTES')
919 }
920 when {
921 allOf {
922 environment name: 'LAVA_TEST', value: 'Enable'
923 }
924 }
925 steps {
926 script {
927 failed_stage = 'Lava test'
928 }
929 unstash 'ci-scripts'
Dean Arnold83f1af22019-05-15 20:58:03 +0100930
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100931 sh '''#!/bin/bash
932 set -e
933 # If no conifig is provided use the built'in
934 if [ -n "${LAVA_TEST_CONFIG_JSON}" ]; then
935 echo "Overriding test config."
936 echo ${LAVA_TEST_CONFIG_JSON} > test_config.json
937 T_CONFIG="--config-file test_config.json"
938 fi
Dean Arnold83f1af22019-05-15 20:58:03 +0100939
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100940 # Generate the lava definition file
941 python3 -u \\
942 ./${TFM_CI_SCR_DIR}/lava_helper/lava_helper.py \\
943 --task-create-definition \\
944 --create-definition-build-no ${BUILD_NUMBER} \\
945 --override-jenkins-url ${JENKINS_URL} \\
946 --override-jenkins-job ${JOB_NAME} \\
947 --create-definition-output-file \\
948 "${LAVA_TEST_DEFINITION}" \\
949 ${T_CONFIG}
Dean Arnold83f1af22019-05-15 20:58:03 +0100950
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100951 # Do not submit invalid jobs
952 if [ ! -f "${LAVA_TEST_DEFINITION}" ]; then
953 echo "LAVA job file does not exist: ${JOB}"
954 exit -1
955 fi
Dean Arnold83f1af22019-05-15 20:58:03 +0100956
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100957 # Convert timeout to seconds
958 DTOUT=$((${LAVA_DISPATCHER_TIMEOUT_MINS} * 60))
Dean Arnold83f1af22019-05-15 20:58:03 +0100959
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100960 # Submit the job to LAVA
961 python3 -u \\
962 ./${TFM_CI_SCR_DIR}/lava_helper/lava_helper.py \\
963 --task-dispatch "$LAVA_TEST_DEFINITION" \\
964 --dispatch-timeout ${DTOUT} \\
965 --dispatch-lava-url ${LAVA_URL} \\
966 --dispatch-lava-job-results-file \\
967 ${LAVA_JOB_RESULTS} \\
968 --dispatch-lava_token_from_environ
Dean Arnold83f1af22019-05-15 20:58:03 +0100969
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100970 # If tokens are not provided withCredentials bidnings
971 # they can be manually set by:
972 # --dispatch-lava_token_usr
973 # --dispatch-lava_token_secret
Dean Arnold83f1af22019-05-15 20:58:03 +0100974
Galanakis, Minosb96c6d42019-06-20 10:41:28 +0100975 # Verify the results and store them into a summary
976 python3 \\
977 ./${TFM_CI_SCR_DIR}/lava_helper/lava_helper.py \\
978 --task-lava-parse ${LAVA_JOB_RESULTS} \\
979 --output-report "${LAVA_SUMMARY_FILE}"
980 '''.stripIndent()
981
982 archiveArtifacts artifacts:
983 "${LAVA_JOB_RESULTS}," +
984 "${LAVA_TEST_DEFINITION}," +
985 "${LAVA_SUMMARY_FILE}",
986 onlyIfSuccessful: false
987
988 stash includes:
989 ("${LAVA_SUMMARY_FILE},"
990 + "${LAVA_JOB_RESULTS},"
991 + "${LAVA_TEST_DEFINITION}"),
992 name: 'lava_summary'
993
994 sh '''#!/bin/bash
995 set -e
996 # Parse the output report(exit(1) if build has failed)
997 python3 \\
998 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
999 --all-fields-must-pass --error_if_failed \\
1000 --set-success-field 'success = True' \\
1001 --report ${LAVA_SUMMARY_FILE}
1002 '''.stripIndent()
1003
1004 script {
1005 lava_job_result = 'SUCCESS'
1006 failed_stage = ''
1007 }
1008 } /* steps */
1009 post {
1010 always {
1011 script {
1012 if (currentBuild.result == 'FAILURE') {
1013 sh '''#!/bin/bash
1014 # If no job has been submittied the file
1015 # will not exist
1016 if [ ! -f lava_job.id ]; then
1017 echo "No LAVA job pending"
1018 exit 0
1019 fi
1020
1021 # Send the request to cancell the job
1022 python3 -u \\
1023 ./${TFM_CI_SCR_DIR}/lava_helper/lava_helper.py \\
1024 --dispatch-lava-url ${LAVA_URL} \\
1025 --dispatch-cancel $(cat lava_job.id) \\
1026 --dispatch-lava_token_from_environ
1027 '''.stripIndent()
1028
1029 } else {
1030 echo "POST: Lava test passed"
1031 }
1032
1033 cleanWs()
1034 } /* script */
1035 } /* always */
1036 } /* post */
1037 } /* stage */
1038 } /* parallel */
1039 } /* stage */
1040
Minos Galanakisda546842018-10-10 17:03:36 +01001041 stage('Proccess Artifacts & Report') {
1042 agent {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +01001043 node {
1044 label docker_img_builder
1045 }
Minos Galanakisda546842018-10-10 17:03:36 +01001046 }
1047 options {
1048 timeout(time: timeout_def_stage, unit:'MINUTES')
1049 }
1050 steps {
Galanakis, Minosb96c6d42019-06-20 10:41:28 +01001051 unstash 'ci_scripts_git_info'
1052 unstash 'nightlies_info'
1053 unstash 'git_info'
1054 unstash 'build_summary'
1055 unstash 'checkpatch_summary'
1056 unstash 'cppcheck_summary'
1057
Minos Galanakisda546842018-10-10 17:03:36 +01001058 script {
1059 failed_stage = 'Proccess Artifacts & Report'
Galanakis, Minosb96c6d42019-06-20 10:41:28 +01001060
1061 if (params.FASTMODEL_TEST.equals('Enable')) {
1062 unstash 'fastmodel_summary'
1063 }
1064 if (params.LAVA_TEST.equals('Enable')) {
1065 unstash 'lava_summary'
1066 }
1067 } /* script */
1068 //Create build result summary to be posted to gerrit.
1069 //Basically contactenate build summary got from downstream jobs
1070 //with a header inserted in between.
1071
1072 /* Unstash the components from previous stages */
1073 unstash 'ci-scripts'
1074
1075 sh '''#!/bin/bash
1076 set -e
1077 # Collect enviroment information
1078 python3 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
1079 --collect --jenkins-info \\
1080 --output-file ${JENKINS_ENV_INFO_FILE}
1081
1082 # Merge all the reports into a summary
1083 REPORT_LIST="cppcheck=${CPPCHCK_SUMMARY_FILE} \\
1084 checkpatch=${CKPATCH_SUMMARY_FILE} \\
1085 build=${BUILD_SUMMARY_FILE} \\
1086 tf-m=${GIT_INFO_FILE} \\
1087 ci-scripts=${CI_SCRIPTS_INFO_FILE} \\
1088 dependencies-info=${DEPENDENCIES_CONTENTS_FILE} \\
1089 jenkings-info=${JENKINS_ENV_INFO_FILE}"
1090
1091 if [ -f "${LAVA_SUMMARY_FILE}" ]; then
1092 REPORT_LIST="${REPORT_LIST} lava=${LAVA_SUMMARY_FILE}"
1093 fi
1094
1095 if [ -f "${FPV_SUMMARY_FILE}" ]; then
1096 REPORT_LIST="${REPORT_LIST} fastmodel=${FPV_SUMMARY_FILE}"
1097 fi
1098
1099 python3 ${TFM_CI_SCR_DIR}/report_parser/report_parser.py \\
1100 --collate-report $REPORT_LIST \\
1101 --output-file ${SUMMARY_FILE}
1102 '''.stripIndent()
1103
1104 /* Archive summary to make it avaibale later. */
1105 archiveArtifacts artifacts: "${SUMMARY_FILE}"
1106
1107 script {
1108 def test_pass = false
1109
Minos Galanakisda546842018-10-10 17:03:36 +01001110 if (cppcheck_job_result == "SUCCESS" && \
1111 checkpath_job_result == "SUCCESS" && \
Galanakis, Minosb96c6d42019-06-20 10:41:28 +01001112 build_job_result == "SUCCESS") {
1113
1114 /* If a test is enabled but failed, then build
1115 has failed */
1116 if (params.FASTMODEL_TEST.equals('Enable') && \
1117 fastmodel_job_result == "FAILURE") {
1118 echo "model testing failed"
1119 currentBuild.result = "FAILURE"
1120 }
1121 else if (params.LAVA_TEST.equals('Enable') && \
1122 lava_job_result == "FAILURE") {
1123 echo "LAVA testing failed"
1124 currentBuild.result = "FAILURE"
1125 }
1126 else {
1127 echo "All jobs have been successfull"
1128 }
Minos Galanakisda546842018-10-10 17:03:36 +01001129 } else {
1130 echo "One or more jobs have failed"
1131 echo "Cppcheck status:"
1132 echo cppcheck_job_result
1133 echo "Checkpatch status:"
1134 echo checkpath_job_result
1135 echo "Build status:"
1136 echo build_job_result
Galanakis, Minosb96c6d42019-06-20 10:41:28 +01001137 echo "Model Test status:"
1138 echo fastmodel_job_result
1139 echo "LAVA Test status:"
Dean Arnold83f1af22019-05-15 20:58:03 +01001140 echo lava_job_result
Minos Galanakisda546842018-10-10 17:03:36 +01001141 currentBuild.result = "FAILURE"
1142 }
Minos Galanakisda546842018-10-10 17:03:36 +01001143
Minos Galanakisda546842018-10-10 17:03:36 +01001144 artifact_job_result = 'SUCCESS'
1145 failed_stage = ''
1146 }
1147 } /* steps */
1148 post {
1149 always {
1150 echo "POST: Proccess Artifacts & Report"
1151 cleanWs()
1152 } /* always */
1153 } /* post */
1154 } /* stage */
1155 } /* stages */
1156 post {
1157 always {
1158 cleanWs()
1159 } /* always */
1160 failure {
1161 script {
1162 if (!(params.MAINTAINER_EMAIL.equals(''))) {
1163 emailext (
1164 subject: ("Job '${env.JOB_NAME}'build "
1165 + "${env.BUILD_NUMBER}, failed at stage: "
1166 + "'${failed_stage}'"),
1167 body: "Check console output at ${env.BUILD_URL}",
1168 to: '${MAINTAINER_EMAIL}',
1169 recipientProviders: [
1170 [$class: ('CulpritsRecipient'
1171 + 'Provider')],
1172 [$class: ('RequesterRecipient'
1173 + 'Provider')]
1174 ]
1175 )
1176 }
1177 } /* script */
1178 } /* failure */
1179 aborted {
1180 script {
1181 if (!(params.MAINTAINER_EMAIL.equals(''))) {
1182 emailext (
1183 subject: ("Job '${env.JOB_NAME}'build "
1184 + "${env.BUILD_NUMBER}, cancelled at stage: "
1185 + "'${failed_stage}'"),
1186 body: "Check console output at ${env.BUILD_URL}",
1187 to: '${MAINTAINER_EMAIL}',
1188 recipientProviders: [
1189 [$class: ('CulpritsRecipient'
1190 + 'Provider')],
1191 [$class: ('RequesterRecipient'
1192 + 'Provider')]
1193 ]
1194 )
1195 }
1196 } /* script */
1197 } /* failure */
1198 } /* post */
1199} /* pipeline */