| #!/usr/bin/env groovy |
| //------------------------------------------------------------------------------- |
| // Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. |
| // |
| // SPDX-License-Identifier: BSD-3-Clause |
| // |
| //------------------------------------------------------------------------------- |
| |
| @NonCPS |
| def getUpstreamJob() { |
| def cause = manager.build.getAction(hudson.model.CauseAction.class).getCauses() |
| return cause |
| } |
| |
| def submitJobs(fvp_only_cmd, bl2_string, psa_string) { |
| dir("tf-m-ci-scripts") { |
| def res = sh(script: """./lava_helper/lava_create_jobs.py \ |
| --build-number ${env.BUILD_NUMBER} --output-dir lava_jobs ${fvp_only_cmd}\ |
| --compiler ${env.COMPILER} --platform ${env.TARGET_PLATFORM} \ |
| ${bl2_string} ${psa_string} --build-type ${env.CMAKE_BUILD_TYPE} \ |
| --jenkins-build-url ${env.BUILD_URL} --proj-config ${env.PROJ_CONFIG} \ |
| --docker-prefix ${env.DOCKER_PREFIX} --license-variable "${env.LICENSE_VARIABLE}" \ |
| --enable-code-coverage "${env.CODE_COVERAGE_EN}" |
| """, returnStdout: true).trim() |
| print(res) |
| job_ids = sh(script: """./lava_helper/lava_submit_jobs.py \ |
| --lava-url ${env.LAVA_URL} --job-dir lava_jobs \ |
| --lava-user ${LAVA_USER} --lava-token ${LAVA_TOKEN} | egrep "^JOBS" |
| """, returnStdout: true).trim() |
| currentBuild.setDescription(job_ids) |
| } |
| } |
| |
| timestamps { |
| node("docker-amd64-tf-m-bionic") { |
| stage("Init") { |
| cleanWs() |
| dir("tf-m-ci-scripts") { |
| checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]]) |
| } |
| } |
| stage("LAVA") { |
| def fvp_only_cmd = "" |
| def upstreamProject = getUpstreamJob()[0].upstreamProject |
| if (upstreamProject == "tf-m-build-and-test") { |
| fvp_only_cmd = "--fvp-only " |
| print("Run test cases only on FVP in per-patch.") |
| } |
| |
| withCredentials([usernamePassword(credentialsId: env.LAVA_CREDENTIALS, passwordVariable: 'LAVA_TOKEN', usernameVariable: 'LAVA_USER')]) { |
| print("Generating LAVA jobs...") |
| def bl2_string = "" |
| def psa_string = "" |
| if (env.BL2.equals("True")) { |
| bl2_string = "--bl2" |
| } |
| // work around this string containing quotes? |
| if (env.PSA_API_SUITE != "") { |
| psa_string = "--psa-api-suite ${env.PSA_API_SUITE}" |
| } |
| try { |
| submitJobs(fvp_only_cmd, bl2_string, psa_string) |
| } catch (Exception ex) { |
| print("LAVA-Submit failed! Exception: ${ex}") |
| print("Try to submit again...") |
| submitJobs(fvp_only_cmd, bl2_string, psa_string) |
| currentBuild.setDescription(currentBuild.getDescription() + " Submitted twice!") |
| } |
| } |
| } |
| stage("Post") { |
| archiveArtifacts artifacts: 'tf-m-ci-scripts/lava_jobs/**', allowEmptyArchive: true |
| cleanWs() |
| } |
| } |
| } |