blob: cf4ae0df67deae064e28bbed9a80171642c11d84 [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 Zhang4c0e1402021-04-26 11:46:47 +080015def submitJobs(fvp_only_cmd, bl2_string, psa_string) {
16 dir("tf-m-ci-scripts") {
17 def res = sh(script: """./lava_helper/lava_create_jobs.py \
18 --build-number ${env.BUILD_NUMBER} --output-dir lava_jobs ${fvp_only_cmd}\
19 --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} \
22 --docker-prefix ${env.DOCKER_PREFIX} --license-variable "${env.LICENSE_VARIABLE}"
23 """, returnStdout: true).trim()
24 print(res)
25 job_ids = sh(script: """./lava_helper/lava_submit_jobs.py \
26 --lava-url ${env.LAVA_URL} --job-dir lava_jobs \
27 --lava-user ${LAVA_USER} --lava-token ${LAVA_TOKEN} | egrep "^JOBS"
28 """, returnStdout: true).trim()
29 currentBuild.setDescription(job_ids)
30 }
31}
32
Xinyu Zhang4cdfd1b2021-05-21 15:10:49 +080033timestamps {
34 node("docker-amd64-tf-m-bionic") {
35 stage("Init") {
36 cleanWs()
37 dir("tf-m-ci-scripts") {
38 checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
39 }
Dean Bircha6ede7e2020-03-13 14:00:33 +000040 }
Xinyu Zhang4cdfd1b2021-05-21 15:10:49 +080041 stage("LAVA") {
42 def fvp_only_cmd = ""
43 def upstreamProject = getUpstreamJob()[0].upstreamProject
44 if (upstreamProject == "tf-m-build-and-test") {
45 fvp_only_cmd = "--fvp-only "
46 print("Run test cases only on FVP in per-patch.")
47 }
Xinyu Zhangbe224f62021-02-03 17:57:38 +080048
Xinyu Zhang4cdfd1b2021-05-21 15:10:49 +080049 withCredentials([usernamePassword(credentialsId: env.LAVA_CREDENTIALS, passwordVariable: 'LAVA_TOKEN', usernameVariable: 'LAVA_USER')]) {
50 print("Generating LAVA jobs...")
51 def bl2_string = ""
52 def psa_string = ""
53 if (env.BL2.equals("True")) {
54 bl2_string = "--bl2"
55 }
56 // work around this string containing quotes?
57 if (env.PSA_API_SUITE != "") {
58 psa_string = "--psa-api-suite ${env.PSA_API_SUITE}"
59 }
60 try {
61 submitJobs(fvp_only_cmd, bl2_string, psa_string)
62 } catch (Exception ex) {
63 print("LAVA-Submit failed! Exception: ${ex}")
64 print("Try to submit again...")
65 submitJobs(fvp_only_cmd, bl2_string, psa_string)
66 currentBuild.setDescription(currentBuild.getDescription() + " Submitted twice!")
67 }
Dean Bircha6ede7e2020-03-13 14:00:33 +000068 }
69 }
Xinyu Zhang4cdfd1b2021-05-21 15:10:49 +080070 stage("Post") {
71 archiveArtifacts artifacts: 'tf-m-ci-scripts/lava_jobs/**', allowEmptyArchive: true
72 cleanWs()
73 }
Dean Bircha6ede7e2020-03-13 14:00:33 +000074 }
75}