blob: f5dc3e926c5861b636db59c04d4224ac12e65848 [file] [log] [blame]
Dean Birch62c4f082020-01-17 16:13:26 +00001#!/usr/bin/env groovy
2//-------------------------------------------------------------------------------
Hugo L'Hostise55a2752021-01-27 11:09:08 +00003// Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
Dean Birch62c4f082020-01-17 16:13:26 +00004//
5// SPDX-License-Identifier: BSD-3-Clause
6//
7//-------------------------------------------------------------------------------
8
Dean Birchd0f9f8c2020-03-26 11:10:33 +00009@Library('trustedfirmware') _
10import org.trustedfirmware.Gerrit
11
Benjamin Copelandbe53b032020-10-30 19:57:59 +000012def nodeLabel = "docker-amd64-tf-m-bionic"
Dean Birchd0f9f8c2020-03-26 11:10:33 +000013if (env.COMPILER == "ARMCLANG") {
Benjamin Copelandbe53b032020-10-30 19:57:59 +000014 nodeLabel = "docker-amd64-tf-m-bionic"
Dean Birchd0f9f8c2020-03-26 11:10:33 +000015}
16
Xinyu Zhangab21b8d2021-04-30 14:15:09 +080017@NonCPS
18def getUpstreamJob() {
19 def cause = manager.build.getAction(hudson.model.CauseAction.class).getCauses()
20 return cause
21}
22
Dean Birchd0f9f8c2020-03-26 11:10:33 +000023node(nodeLabel) {
Dean Birch62c4f082020-01-17 16:13:26 +000024 stage("Init") {
25 cleanWs()
26 dir("trusted-firmware-m") {
27 checkout(
28 poll: false,
29 scm: [
30 $class: 'GitSCM',
31 branches: [[name: '$GERRIT_BRANCH']],
32 extensions: [[$class: 'BuildChooserSetting', buildChooser: [$class: 'GerritTriggerBuildChooser']]],
33 userRemoteConfigs: [[
34 credentialsId: 'GIT_SSH_KEY',
35 refspec: '$GERRIT_REFSPEC', url: '$CODE_REPO'
36 ]]
37 ])
38 }
39 dir("tf-m-ci-scripts") {
Colin Thorbinson58703db2020-11-24 12:02:19 +000040 checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
Dean Birch62c4f082020-01-17 16:13:26 +000041 }
Karl Zhang02d30352020-08-20 13:48:52 +080042 dir("mbedtls") {
43 checkout(
44 changelog: false,
45 poll: false,
46 scm: [
47 $class: 'GitSCM',
48 branches: [[name: 'FETCH_HEAD']],
49 userRemoteConfigs: [[
50 refspec: 'refs/tags/$MBEDTLS_VERSION',
51 url: params.MBEDTLS_URL
52 ]]
53 ]
54 )
55 }
Tamas Ban260faf42020-06-08 16:14:55 +010056 dir("mcuboot") {
57 checkout(
58 changelog: false,
59 poll: false,
60 scm: [
61 $class: 'GitSCM',
62 branches: [[name: 'FETCH_HEAD']],
63 userRemoteConfigs: [[
Tamas Ban1f1213e2020-09-25 12:38:31 +010064 refspec: '$MCUBOOT_REFSPEC',
Tamas Ban260faf42020-06-08 16:14:55 +010065 url: params.MCUBOOT_URL
66 ]]
67 ]
68 )
69 }
Kevin Pengb0bc0d12020-06-17 14:17:03 +080070 dir("tf-m-tests") {
71 checkout(
72 changelog: false,
73 poll: false,
74 scm: [
75 $class: 'GitSCM',
76 branches: [[name: 'FETCH_HEAD']],
77 userRemoteConfigs: [[
78 refspec: '$TFM_TESTS_REFSPEC',
79 url: params.TFM_TESTS_URL
80 ]]
81 ]
82 )
83 }
Dean Birchd0f9f8c2020-03-26 11:10:33 +000084 if (env.PSA_API_SUITE != "") {
85 dir("psa-arch-tests") {
86 checkout(
87 changelog: false,
88 poll: false,
89 scm: [
90 $class: 'GitSCM',
91 branches: [[name: 'FETCH_HEAD']],
92 userRemoteConfigs: [[
Karl Zhanga6820f22020-06-17 11:34:06 +080093 refspec: '$PSA_ARCH_TESTS_VERSION',
Matthew Hartfb6fd362020-03-04 21:03:59 +000094 url: params.PSA_ARCH_TESTS_URL
Dean Birchd0f9f8c2020-03-26 11:10:33 +000095 ]]
96 ]
97 )
98 }
99 }
Dean Birch62c4f082020-01-17 16:13:26 +0000100 }
Dean Birchd0f9f8c2020-03-26 11:10:33 +0000101 try {
102 verify = 1
103 stage("Build") {
Riku Voipiod78059f2020-09-10 13:35:13 +0300104 sh "tf-m-ci-scripts/run-build.sh"
Dean Birchd0f9f8c2020-03-26 11:10:33 +0000105 }
106 stage("Post") {
Xinyu Zhang694eb492020-11-04 18:29:08 +0800107 archiveArtifacts 'trusted-firmware-m/build/bin/**'
Xinyu Zhang840a5282020-12-30 15:28:56 +0800108 archiveArtifacts 'trusted-firmware-m/build/install/interface/**'
Xinyu Zhangab21b8d2021-04-30 14:15:09 +0800109 def upstreamProject = getUpstreamJob()[0].upstreamProject
110 if (upstreamProject == "tf-m-build-and-test") {
111 archiveArtifacts 'trusted-firmware-m/build/generated/**'
112 }
Hugo L'Hostise55a2752021-01-27 11:09:08 +0000113 if (env.SQUAD_CONFIGURATIONS != ""){
114 //Creating a folder to store memory footprint artifacts and launching the memory footprint script.
115 sh "mkdir tf-m-ci-scripts/Memory_footprint/"
116 withCredentials([string(credentialsId: 'QA_REPORTS_TOKEN', variable: 'TOKEN')]) {
117 sh(script: "python3 tf-m-ci-scripts/memory_footprint.py ${env.WORKSPACE}/trusted-firmware-m/ ${env.CONFIG_NAME} \'${env.SQUAD_CONFIGURATIONS}\' ${TOKEN}", returnStdout: true)
118 }
119 if (fileExists('tf-m-ci-scripts/Memory_footprint/filesize.json')) {
120 archiveArtifacts 'tf-m-ci-scripts/Memory_footprint/filesize.json'
121 }
122 }
Dean Birchd0f9f8c2020-03-26 11:10:33 +0000123 }
124 } catch (Exception e) {
125 manager.buildFailure()
126 verify = -1
127 } finally {
128 g = new Gerrit()
129 g.verifyStatusInWorkspace(verify, env.CONFIG_NAME, 'build')
Matthew Hartfb6fd362020-03-04 21:03:59 +0000130 def buildStatus = (verify == 1) ? 'Successful' : 'Failed'
131 //g.commentInWorkspace("Build configuration ${env.CONFIG_NAME} ${buildStatus}: ${env.RUN_DISPLAY_URL}")
Dean Birch62c4f082020-01-17 16:13:26 +0000132 cleanWs()
133 }
134}