blob: efcc755230b93d99b163ca47c0fa3ae86e7c6630 [file] [log] [blame]
Dean Bircha6ede7e2020-03-13 14:00:33 +00001#!/usr/bin/env groovy
2//-------------------------------------------------------------------------------
Xinyu Zhangbe224f62021-02-03 17:57:38 +08003// Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
Dean Bircha6ede7e2020-03-13 14:00:33 +00004//
5// SPDX-License-Identifier: BSD-3-Clause
6//
7//-------------------------------------------------------------------------------
8
Xinyu Zhangbe224f62021-02-03 17:57:38 +08009@NonCPS
10def getUpstreamJob() {
11 def cause = manager.build.getAction(hudson.model.CauseAction.class).getCauses()
12 return cause
13}
14
Xinyu Zhang302b74d2021-11-03 14:53:44 +080015def submitJobs(device_type, bl2_string, psa_string) {
Xinyu Zhang4c0e1402021-04-26 11:46:47 +080016 dir("tf-m-ci-scripts") {
17 def res = sh(script: """./lava_helper/lava_create_jobs.py \
Xinyu Zhang302b74d2021-11-03 14:53:44 +080018 --build-number ${env.BUILD_NUMBER} --output-dir lava_jobs ${device_type}\
Xinyu Zhang4c0e1402021-04-26 11:46:47 +080019 --compiler ${env.COMPILER} --platform ${env.TARGET_PLATFORM} \
20 ${bl2_string} ${psa_string} --build-type ${env.CMAKE_BUILD_TYPE} \
21 --jenkins-build-url ${env.BUILD_URL} --proj-config ${env.PROJ_CONFIG} \
Leonardo Sandoval12fbb2f2021-04-15 14:36:09 -050022 --docker-prefix ${env.DOCKER_PREFIX} --license-variable "${env.LICENSE_VARIABLE}" \
23 --enable-code-coverage "${env.CODE_COVERAGE_EN}"
Xinyu Zhang4c0e1402021-04-26 11:46:47 +080024 """, returnStdout: true).trim()
25 print(res)
26 job_ids = sh(script: """./lava_helper/lava_submit_jobs.py \
27 --lava-url ${env.LAVA_URL} --job-dir lava_jobs \
28 --lava-user ${LAVA_USER} --lava-token ${LAVA_TOKEN} | egrep "^JOBS"
29 """, returnStdout: true).trim()
Paul Sokolovsky79b9d372022-01-05 14:03:14 +030030 print("${job_ids}")
Xinyu Zhang4c0e1402021-04-26 11:46:47 +080031 currentBuild.setDescription(job_ids)
32 }
33}
34
Xinyu Zhang4cdfd1b2021-05-21 15:10:49 +080035timestamps {
36 node("docker-amd64-tf-m-bionic") {
37 stage("Init") {
38 cleanWs()
39 dir("tf-m-ci-scripts") {
40 checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
41 }
Dean Bircha6ede7e2020-03-13 14:00:33 +000042 }
Xinyu Zhang4cdfd1b2021-05-21 15:10:49 +080043 stage("LAVA") {
Xinyu Zhang302b74d2021-11-03 14:53:44 +080044 def device_type = ""
Xinyu Zhang4cdfd1b2021-05-21 15:10:49 +080045 def upstreamProject = getUpstreamJob()[0].upstreamProject
Leonardo Sandoval66eed7a2021-12-03 10:33:31 -060046 if (upstreamProject == "tf-m-build-and-test") {
47 device_type = "--physical-board-only "
48 print("Run test cases only on physical boards in per-patch.")
49 }
Xinyu Zhangbe224f62021-02-03 17:57:38 +080050
Xinyu Zhang4cdfd1b2021-05-21 15:10:49 +080051 withCredentials([usernamePassword(credentialsId: env.LAVA_CREDENTIALS, passwordVariable: 'LAVA_TOKEN', usernameVariable: 'LAVA_USER')]) {
52 print("Generating LAVA jobs...")
53 def bl2_string = ""
54 def psa_string = ""
55 if (env.BL2.equals("True")) {
56 bl2_string = "--bl2"
57 }
58 // work around this string containing quotes?
59 if (env.PSA_API_SUITE != "") {
60 psa_string = "--psa-api-suite ${env.PSA_API_SUITE}"
61 }
62 try {
Xinyu Zhang302b74d2021-11-03 14:53:44 +080063 submitJobs(device_type, bl2_string, psa_string)
Xinyu Zhang4cdfd1b2021-05-21 15:10:49 +080064 } catch (Exception ex) {
65 print("LAVA-Submit failed! Exception: ${ex}")
66 print("Try to submit again...")
Xinyu Zhang302b74d2021-11-03 14:53:44 +080067 submitJobs(device_type, bl2_string, psa_string)
Xinyu Zhang4cdfd1b2021-05-21 15:10:49 +080068 currentBuild.setDescription(currentBuild.getDescription() + " Submitted twice!")
69 }
Dean Bircha6ede7e2020-03-13 14:00:33 +000070 }
71 }
Xinyu Zhang4cdfd1b2021-05-21 15:10:49 +080072 stage("Post") {
73 archiveArtifacts artifacts: 'tf-m-ci-scripts/lava_jobs/**', allowEmptyArchive: true
74 cleanWs()
75 }
Dean Bircha6ede7e2020-03-13 14:00:33 +000076 }
77}