blob: 989b7fe428c077e6950f5b0279e31f54472a05aa [file] [log] [blame]
Dean Birchd0f9f8c2020-03-26 11:10:33 +00001/*
2 * Copyright (c) 2020, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8package org.trustedfirmware
9
Paul Sokolovsky741b30b2024-07-05 12:21:20 +030010
11def checkout_ci_scripts() {
12 checkout([
13 $class: 'GitSCM',
14 branches: [[name: '$CI_SCRIPTS_BRANCH']],
15 userRemoteConfigs: [[
16 credentialsId: 'GIT_SSH_KEY',
17 url: '$CI_SCRIPTS_REPO',
18 refspec: '+refs/heads/*:refs/remotes/origin/* +refs/changes/*:refs/remotes/origin/refs/changes/*'
19 ]]
20 ])
21}
22
Dean Birchd0f9f8c2020-03-26 11:10:33 +000023def verifyStatus(value, verify_name, category) {
Paul Sokolovskye1ad4772024-03-07 00:08:27 +070024 node("docker-amd64-tf-m-jammy") {
Dean Birchd0f9f8c2020-03-26 11:10:33 +000025 cleanWs()
26 dir("tf-m-ci-scripts") {
Paul Sokolovsky741b30b2024-07-05 12:21:20 +030027 checkout_ci_scripts()
Dean Birchd0f9f8c2020-03-26 11:10:33 +000028 }
29 verifyStatusInWorkspace(value, verify_name, category)
30 }
31}
32
33def verifyStatusInWorkspace(value, verify_name, category) {
34 withCredentials([usernamePassword(credentialsId: 'VERIFY_STATUS', passwordVariable: 'VERIFY_PASSWORD', usernameVariable: 'VERIFY_USER')]) {
35 sh("""
Dean Birch7fabf4d2020-05-29 16:20:15 +010036 set +e
Dean Birchd0f9f8c2020-03-26 11:10:33 +000037 if [ -z "\$GERRIT_HOST" ] ; then
38 echo Not running for a Gerrit change, skipping vote.
39 exit 0
40 fi
41 if [ ! -d venv ] ; then
42 virtualenv -p \$(which python3) venv
43 fi
44 . venv/bin/activate
45 pip -q install requests
46 ./tf-m-ci-scripts/jenkins/verify.py --category ${category} --value ${value} --verify-name ${verify_name} --user \$VERIFY_USER
47 """)
48 }
49}
50
51def comment(comment) {
Paul Sokolovskye1ad4772024-03-07 00:08:27 +070052 node("docker-amd64-tf-m-jammy") {
Dean Birchd0f9f8c2020-03-26 11:10:33 +000053 cleanWs()
54 dir("tf-m-ci-scripts") {
Paul Sokolovsky741b30b2024-07-05 12:21:20 +030055 checkout_ci_scripts()
Dean Birchd0f9f8c2020-03-26 11:10:33 +000056 }
57 commentInWorkspace(comment)
58 }
59}
60
61def commentInWorkspace(comment) {
62 withCredentials([usernamePassword(credentialsId: 'VERIFY_STATUS', passwordVariable: 'GERRIT_PASSWORD', usernameVariable: 'GERRIT_USER')]) {
63 sh("""
64 if [ -z "\$GERRIT_HOST" ] ; then
65 echo Not running for a Gerrit change, skipping.
66 exit 0
67 fi
68 if [ ! -d venv ] ; then
69 virtualenv -p \$(which python3) venv
70 fi
71 . venv/bin/activate
72 pip -q install requests
73 ./tf-m-ci-scripts/jenkins/comment.py --comment "${comment}" --user \$GERRIT_USER
74 """)
75 }
76}