blob: 8df8af059ededd9eaeb40208321a07e59ee358c0 [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
Matthew Dalzella1717812025-08-05 17:24:22 +010041
42 if [ -d "./.venv" ]; then
43 . /.venv/bin/activate
44 elif [ -d "/home/buildslave/.venv" ]; then
45 . /home/buildslave/.venv/bin/activate
46 fi
47
Dean Birchd0f9f8c2020-03-26 11:10:33 +000048 pip -q install requests
49 ./tf-m-ci-scripts/jenkins/verify.py --category ${category} --value ${value} --verify-name ${verify_name} --user \$VERIFY_USER
50 """)
51 }
52}
53
54def comment(comment) {
Paul Sokolovskye1ad4772024-03-07 00:08:27 +070055 node("docker-amd64-tf-m-jammy") {
Dean Birchd0f9f8c2020-03-26 11:10:33 +000056 cleanWs()
57 dir("tf-m-ci-scripts") {
Paul Sokolovsky741b30b2024-07-05 12:21:20 +030058 checkout_ci_scripts()
Dean Birchd0f9f8c2020-03-26 11:10:33 +000059 }
60 commentInWorkspace(comment)
61 }
62}
63
64def commentInWorkspace(comment) {
65 withCredentials([usernamePassword(credentialsId: 'VERIFY_STATUS', passwordVariable: 'GERRIT_PASSWORD', usernameVariable: 'GERRIT_USER')]) {
66 sh("""
67 if [ -z "\$GERRIT_HOST" ] ; then
68 echo Not running for a Gerrit change, skipping.
69 exit 0
70 fi
Matthew Dalzella1717812025-08-05 17:24:22 +010071
72 if [ -d "./.venv" ]; then
73 . /.venv/bin/activate
74 elif [ -d "/home/buildslave/.venv" ]; then
75 . /home/buildslave/.venv/bin/activate
76 fi
77
Dean Birchd0f9f8c2020-03-26 11:10:33 +000078 pip -q install requests
79 ./tf-m-ci-scripts/jenkins/comment.py --comment "${comment}" --user \$GERRIT_USER
80 """)
81 }
82}