Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 1 | #!/usr/bin/env groovy |
| 2 | //------------------------------------------------------------------------------- |
Xinyu Zhang | be224f6 | 2021-02-03 17:57:38 +0800 | [diff] [blame] | 3 | // Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 4 | // |
| 5 | // SPDX-License-Identifier: BSD-3-Clause |
| 6 | // |
| 7 | //------------------------------------------------------------------------------- |
| 8 | |
Xinyu Zhang | be224f6 | 2021-02-03 17:57:38 +0800 | [diff] [blame] | 9 | @NonCPS |
| 10 | def getUpstreamJob() { |
| 11 | def cause = manager.build.getAction(hudson.model.CauseAction.class).getCauses() |
| 12 | return cause |
| 13 | } |
| 14 | |
Benjamin Copeland | be53b03 | 2020-10-30 19:57:59 +0000 | [diff] [blame] | 15 | node("docker-amd64-tf-m-bionic") { |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 16 | stage("Init") { |
| 17 | cleanWs() |
| 18 | dir("tf-m-ci-scripts") { |
Colin Thorbinson | 58703db | 2020-11-24 12:02:19 +0000 | [diff] [blame] | 19 | checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]]) |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 20 | } |
| 21 | } |
| 22 | stage("LAVA") { |
Xinyu Zhang | be224f6 | 2021-02-03 17:57:38 +0800 | [diff] [blame] | 23 | |
| 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 Birch | 956416f | 2020-08-12 10:36:16 +0100 | [diff] [blame] | 31 | withCredentials([usernamePassword(credentialsId: env.LAVA_CREDENTIALS, passwordVariable: 'LAVA_TOKEN', usernameVariable: 'LAVA_USER')]) { |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 32 | print("Generating LAVA jobs...") |
| 33 | def bl2_string = "" |
Matthew Hart | 2c2688f | 2020-05-26 13:09:20 +0100 | [diff] [blame] | 34 | def psa_string = "" |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 35 | if (env.BL2.equals("True")) { |
| 36 | bl2_string = "--bl2" |
| 37 | } |
Matthew Hart | 2c2688f | 2020-05-26 13:09:20 +0100 | [diff] [blame] | 38 | // work around this string containing quotes? |
Xinyu Zhang | 5c4bbca | 2020-09-24 16:36:03 +0800 | [diff] [blame] | 39 | if (env.PSA_API_SUITE != "") { |
Matthew Hart | 2c2688f | 2020-05-26 13:09:20 +0100 | [diff] [blame] | 40 | psa_string = "--psa-api-suite ${env.PSA_API_SUITE}" |
| 41 | } |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 42 | dir("tf-m-ci-scripts") { |
| 43 | def res = sh(script: """./lava_helper/lava_create_jobs.py \ |
Xinyu Zhang | be224f6 | 2021-02-03 17:57:38 +0800 | [diff] [blame] | 44 | --build-number ${env.BUILD_NUMBER} --output-dir lava_jobs ${fvp_only_cmd}\ |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 45 | --compiler ${env.COMPILER} --platform ${env.TARGET_PLATFORM} \ |
Matthew Hart | 2c2688f | 2020-05-26 13:09:20 +0100 | [diff] [blame] | 46 | ${bl2_string} ${psa_string} --build-type ${env.CMAKE_BUILD_TYPE} \ |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 47 | --jenkins-build-url ${env.BUILD_URL} --proj-config ${env.PROJ_CONFIG} \ |
| 48 | --docker-prefix ${env.DOCKER_PREFIX} --license-variable "${env.LICENSE_VARIABLE}" |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 49 | """, returnStdout: true).trim() |
| 50 | print(res) |
| 51 | job_ids = sh(script: """./lava_helper/lava_submit_jobs.py \ |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 52 | --lava-url ${env.LAVA_URL} --job-dir lava_jobs \ |
| 53 | --lava-user ${LAVA_USER} --lava-token ${LAVA_TOKEN} | egrep "^JOBS" |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 54 | """, 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 | } |