blob: 9f52c627a4debbc1f152c1635cfdbb0fef9c28d8 [file] [log] [blame]
Dean Birch62c4f082020-01-17 16:13:26 +00001#!/usr/bin/env groovy
2//-------------------------------------------------------------------------------
3// Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
4//
5// SPDX-License-Identifier: BSD-3-Clause
6//
7//-------------------------------------------------------------------------------
8
9def listConfigs(ci_scripts_dir, config_list, filter_group) {
10 dir(ci_scripts_dir) {
11 echo "Obtaining list of configs."
12 echo "Running: ./configs.py -g ${filter_group}"
13 def build_config_list_raw = sh(script: """\
14./configs.py -g ${filter_group}
15""", returnStdout: true).trim()
16 def build_config_list = build_config_list_raw.tokenize('\n')
17 config_list.addAll(build_config_list)
18 }
19}
20
21def buildConfig(ci_scripts_dir, config, filter_group) {
22 def params = []
23 def build_config_params
24 dir(ci_scripts_dir) {
25 echo "Obtaining build configuration for config ${config}"
26 echo "Running: ./configs.py -g ${filter_group} ${config}"
27 build_config_params = sh(script: """\
28./configs.py -g ${filter_group} ${config}
29""", returnStdout: true).trim()
30 }
31 def lines = build_config_params.tokenize('\n')
32 for (String line : lines) {
33 def key, value
34 (key, value) = line.tokenize('=')
35 params += string(name: key, value: value)
36 }
37 params += string(name: 'GERRIT_BRANCH', value: env.GERRIT_BRANCH)
38 params += string(name: 'GERRIT_REFSPEC', value: env.GERRIT_REFSPEC)
39 params += string(name: 'CMSIS_VERSION', value: env.CMSIS_VERSION)
40 params += string(name: 'MBEDCRYPTO_VERSION', value: env.MBEDCRYPTO_VERSION)
41 params += string(name: 'CODE_REPO', value: env.CODE_REPO)
42 return {
43 def res = build(job: 'tf-m-build-config', parameters: params, propagate: false)
44 print("${res.number}: ${config} ${res.result} ${res.getAbsoluteUrl()}")
45 if (res.result == "FAILURE") {
46 error("Build failed at ${res.getAbsoluteUrl()}")
47 }
48 }
49}
50
51def buildDocs() {
52 def params = []
53 params += string(name: 'GERRIT_BRANCH', value: env.GERRIT_BRANCH)
54 params += string(name: 'GERRIT_REFSPEC', value: env.GERRIT_REFSPEC)
55 params += string(name: 'CMSIS_VERSION', value: env.CMSIS_VERSION)
56 params += string(name: 'MBEDCRYPTO_VERSION', value: env.MBEDCRYPTO_VERSION)
57 params += string(name: 'CODE_REPO', value: env.CODE_REPO)
58 return {
59 def res = build(job: 'tf-m-build-docs', parameters: params, propagate:false)
60 print("${res.number}: Docs ${res.result} ${res.getAbsoluteUrl()}")
61 if (res.result == "FAILURE") {
62 error("Build failed at ${res.getAbsoluteUrl()}")
63 }
64 }
65}
66
67def verifyStatus(value, stage_name) {
68 node("docker-amd64-xenial") {
69 cleanWs()
70 dir("tf-m-ci-scripts") {
71 git url: '$CI_SCRIPTS_REPO', branch: 'master', credentialsId: 'GIT_SSH_KEY'
72 }
73 withCredentials([usernamePassword(credentialsId: 'VERIFY_STATUS', passwordVariable: 'VERIFY_PASSWORD', usernameVariable: 'VERIFY_USER')]) {
74 sh("""
75 if [ -z "\$GERRIT_HOST" ] ; then
76 echo Not running for a Gerrit change, skipping vote.
77 exit 0
78 fi
79 if [ ! -d venv ] ; then
80 virtualenv -p \$(which python3) venv
81 fi
82 . venv/bin/activate
83 pip -q install requests
84 ./tf-m-ci-scripts/jenkins/verify.py --value ${value} --verify-name tf-m-${stage_name} --user \$VERIFY_USER
85 """)
86 }
87 }
88}
89
90def configs = []
91def builds = [:]
92
93node("master") {
94 stage("Init") {
95 cleanWs()
96 dir("tf-m-ci-scripts") {
97 git url: '$CI_SCRIPTS_REPO', branch: 'master', credentialsId: 'GIT_SSH_KEY'
98 }
99 }
100 stage("Configs") {
101 // Populate configs
102 listConfigs('tf-m-ci-scripts', configs, env.FILTER_GROUP)
103 for (config in configs) {
104 builds[config] = buildConfig("tf-m-ci-scripts", config, env.FILTER_GROUP)
105 }
106 builds["docs"] = buildDocs()
107 }
108}
109stage("Builds") {
110 def verify = 1
111 try {
112 parallel(builds)
113 } catch (Exception e) {
114 manager.buildFailure()
115 verify = -1
116 } finally {
117 verifyStatus(verify, 'build')
118 }
119}
120// TODO Test phase