blob: 3ce8acd03ebe259f754b35c7686c860805aae7bc [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
Xinyu Zhang4cdfd1b2021-05-21 15:10:49 +080023timestamps {
24 node(nodeLabel) {
25 stage("Init") {
26 cleanWs()
27 dir("trusted-firmware-m") {
28 checkout(
29 poll: false,
30 scm: [
31 $class: 'GitSCM',
32 branches: [[name: '$GERRIT_BRANCH']],
33 extensions: [[$class: 'BuildChooserSetting', buildChooser: [$class: 'GerritTriggerBuildChooser']]],
34 userRemoteConfigs: [[
35 credentialsId: 'GIT_SSH_KEY',
36 refspec: '$GERRIT_REFSPEC', url: '$CODE_REPO'
37 ]]
38 ])
39 }
40 dir("tf-m-ci-scripts") {
41 checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
42 }
43 dir("mbedtls") {
Dean Birchd0f9f8c2020-03-26 11:10:33 +000044 checkout(
45 changelog: false,
46 poll: false,
47 scm: [
48 $class: 'GitSCM',
49 branches: [[name: 'FETCH_HEAD']],
50 userRemoteConfigs: [[
Xinyu Zhang4cdfd1b2021-05-21 15:10:49 +080051 refspec: 'refs/tags/$MBEDTLS_VERSION',
52 url: params.MBEDTLS_URL
Dean Birchd0f9f8c2020-03-26 11:10:33 +000053 ]]
54 ]
55 )
56 }
Xinyu Zhang4cdfd1b2021-05-21 15:10:49 +080057 dir("mcuboot") {
58 checkout(
59 changelog: false,
60 poll: false,
61 scm: [
62 $class: 'GitSCM',
63 branches: [[name: 'FETCH_HEAD']],
64 userRemoteConfigs: [[
65 refspec: '$MCUBOOT_REFSPEC',
66 url: params.MCUBOOT_URL
67 ]]
68 ]
69 )
Xinyu Zhangab21b8d2021-04-30 14:15:09 +080070 }
Xinyu Zhang4cdfd1b2021-05-21 15:10:49 +080071 dir("tf-m-tests") {
72 checkout(
73 changelog: false,
74 poll: false,
75 scm: [
76 $class: 'GitSCM',
77 branches: [[name: 'FETCH_HEAD']],
78 userRemoteConfigs: [[
79 refspec: '$TFM_TESTS_REFSPEC',
80 url: params.TFM_TESTS_URL
81 ]]
82 ]
83 )
84 }
85 if (env.PSA_API_SUITE != "") {
86 dir("psa-arch-tests") {
87 checkout(
88 changelog: false,
89 poll: false,
90 scm: [
91 $class: 'GitSCM',
92 branches: [[name: 'FETCH_HEAD']],
93 userRemoteConfigs: [[
94 refspec: '$PSA_ARCH_TESTS_VERSION',
95 url: params.PSA_ARCH_TESTS_URL
96 ]]
97 ]
98 )
Hugo L'Hostise55a2752021-01-27 11:09:08 +000099 }
100 }
Dean Birchd0f9f8c2020-03-26 11:10:33 +0000101 }
Xinyu Zhang4cdfd1b2021-05-21 15:10:49 +0800102 try {
103 verify = 1
104 stage("Build") {
105 sh "tf-m-ci-scripts/run-build.sh"
106 }
107 stage("Post") {
108 archiveArtifacts 'trusted-firmware-m/build/bin/**'
109 archiveArtifacts 'trusted-firmware-m/build/install/interface/**'
110 def upstreamProject = getUpstreamJob()[0].upstreamProject
111 if (upstreamProject == "tf-m-build-and-test") {
112 archiveArtifacts 'trusted-firmware-m/build/generated/**'
113 }
114 if (env.SQUAD_CONFIGURATIONS != ""){
115 //Creating a folder to store memory footprint artifacts and launching the memory footprint script.
116 sh "mkdir tf-m-ci-scripts/Memory_footprint/"
117 withCredentials([string(credentialsId: 'QA_REPORTS_TOKEN', variable: 'TOKEN')]) {
118 sh(script: "python3 tf-m-ci-scripts/memory_footprint.py ${env.WORKSPACE}/trusted-firmware-m/ ${env.CONFIG_NAME} \'${env.SQUAD_CONFIGURATIONS}\' ${TOKEN}", returnStdout: true)
119 }
120 if (fileExists('tf-m-ci-scripts/Memory_footprint/filesize.json')) {
121 archiveArtifacts 'tf-m-ci-scripts/Memory_footprint/filesize.json'
122 }
123 }
124 }
125 } catch (Exception e) {
126 manager.buildFailure()
127 verify = -1
128 } finally {
129 g = new Gerrit()
130 g.verifyStatusInWorkspace(verify, env.CONFIG_NAME, 'build')
131 def buildStatus = (verify == 1) ? 'Successful' : 'Failed'
132 //g.commentInWorkspace("Build configuration ${env.CONFIG_NAME} ${buildStatus}: ${env.RUN_DISPLAY_URL}")
133 cleanWs()
134 }
Dean Birch62c4f082020-01-17 16:13:26 +0000135 }
136}