blob: 84eaf7880ee03db0d13f2bebfab3b5bde7bfa2cb [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
Benjamin Copelandbe53b032020-10-30 19:57:59 +000015node("docker-amd64-tf-m-bionic") {
Dean Bircha6ede7e2020-03-13 14:00:33 +000016 stage("Init") {
17 cleanWs()
18 dir("tf-m-ci-scripts") {
Colin Thorbinson58703db2020-11-24 12:02:19 +000019 checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
Dean Bircha6ede7e2020-03-13 14:00:33 +000020 }
21 }
22 stage("LAVA") {
Xinyu Zhangbe224f62021-02-03 17:57:38 +080023
24 def fvp_only_cmd = ""
25 def upstreamProject = getUpstreamJob()[0].upstreamProject
26 if (upstreamProject == "tf-m-build-and-test") {
27 fvp_only_cmd = "--fvp-only "
28 print("Run test cases only on FVP in per-patch.")
29 }
30
Dean Birch956416f2020-08-12 10:36:16 +010031 withCredentials([usernamePassword(credentialsId: env.LAVA_CREDENTIALS, passwordVariable: 'LAVA_TOKEN', usernameVariable: 'LAVA_USER')]) {
Dean Bircha6ede7e2020-03-13 14:00:33 +000032 print("Generating LAVA jobs...")
33 def bl2_string = ""
Matthew Hart2c2688f2020-05-26 13:09:20 +010034 def psa_string = ""
Dean Bircha6ede7e2020-03-13 14:00:33 +000035 if (env.BL2.equals("True")) {
36 bl2_string = "--bl2"
37 }
Matthew Hart2c2688f2020-05-26 13:09:20 +010038 // work around this string containing quotes?
Xinyu Zhang5c4bbca2020-09-24 16:36:03 +080039 if (env.PSA_API_SUITE != "") {
Matthew Hart2c2688f2020-05-26 13:09:20 +010040 psa_string = "--psa-api-suite ${env.PSA_API_SUITE}"
41 }
Dean Bircha6ede7e2020-03-13 14:00:33 +000042 dir("tf-m-ci-scripts") {
43 def res = sh(script: """./lava_helper/lava_create_jobs.py \
Xinyu Zhangbe224f62021-02-03 17:57:38 +080044--build-number ${env.BUILD_NUMBER} --output-dir lava_jobs ${fvp_only_cmd}\
Dean Bircha6ede7e2020-03-13 14:00:33 +000045--compiler ${env.COMPILER} --platform ${env.TARGET_PLATFORM} \
Matthew Hart2c2688f2020-05-26 13:09:20 +010046${bl2_string} ${psa_string} --build-type ${env.CMAKE_BUILD_TYPE} \
Matthew Hartfb6fd362020-03-04 21:03:59 +000047--jenkins-build-url ${env.BUILD_URL} --proj-config ${env.PROJ_CONFIG} \
48--docker-prefix ${env.DOCKER_PREFIX} --license-variable "${env.LICENSE_VARIABLE}"
Dean Bircha6ede7e2020-03-13 14:00:33 +000049""", returnStdout: true).trim()
50 print(res)
51 job_ids = sh(script: """./lava_helper/lava_submit_jobs.py \
Matthew Hartfb6fd362020-03-04 21:03:59 +000052 --lava-url ${env.LAVA_URL} --job-dir lava_jobs \
53 --lava-user ${LAVA_USER} --lava-token ${LAVA_TOKEN} | egrep "^JOBS"
Dean Bircha6ede7e2020-03-13 14:00:33 +000054 """, returnStdout: true).trim()
55 currentBuild.setDescription(job_ids)
56 }
57 }
58 }
59 stage("Post") {
60 archiveArtifacts artifacts: 'tf-m-ci-scripts/lava_jobs/**', allowEmptyArchive: true
61 cleanWs()
62 }
63}