Paul Sokolovsky | b1ba645 | 2022-09-06 15:57:47 +0300 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
Paul Sokolovsky | 3a1f816 | 2022-10-21 18:32:07 +0300 | [diff] [blame] | 3 | # Copyright (c) 2019-2022, Arm Limited. All rights reserved. |
Paul Sokolovsky | b1ba645 | 2022-09-06 15:57:47 +0300 | [diff] [blame] | 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | set -ex |
| 8 | |
Paul Sokolovsky | 3a1f816 | 2022-10-21 18:32:07 +0300 | [diff] [blame] | 9 | # Set to 0 to temporarily disable posting comments to Gerrit. |
| 10 | should_post_comment=1 |
Paul Sokolovsky | b1ba645 | 2022-09-06 15:57:47 +0300 | [diff] [blame] | 11 | |
Paul Sokolovsky | 7371798 | 2022-12-28 19:51:47 +0300 | [diff] [blame] | 12 | # Directory where this script resides. |
| 13 | SCRIPT_DIR="$(cd "$(dirname "$0")" ; echo "${PWD}")" |
| 14 | |
Paul Sokolovsky | 3a1f816 | 2022-10-21 18:32:07 +0300 | [diff] [blame] | 15 | # Don't post comments if run on the staging server. |
Saheer Babu | bdb0d65 | 2025-02-10 14:08:20 +0000 | [diff] [blame] | 16 | if echo "$JENKINS_PUBLIC_URL" | grep -q "ci\.staging"; then |
Paul Sokolovsky | 3a1f816 | 2022-10-21 18:32:07 +0300 | [diff] [blame] | 17 | should_post_comment=0 |
| 18 | fi |
| 19 | |
| 20 | # Always enable posting comments to sandbox (test) projects, even if they're |
| 21 | # disabled above. |
Paul Sokolovsky | b1ba645 | 2022-09-06 15:57:47 +0300 | [diff] [blame] | 22 | if echo "${GERRIT_PROJECT}" | grep -q sandbox; then |
| 23 | should_post_comment=1 |
| 24 | fi |
| 25 | |
| 26 | if [ $should_post_comment -eq 1 ]; then |
| 27 | mkdir -p ~/.ssh/ |
| 28 | ssh-keyscan -H -p 29418 $GERRIT_HOST >> ~/.ssh/known_hosts |
| 29 | |
Paul Sokolovsky | 7371798 | 2022-12-28 19:51:47 +0300 | [diff] [blame] | 30 | quoted="$(python3 $SCRIPT_DIR/prepare_gerrit_comment.py misra_delta.txt)" |
Paul Sokolovsky | b1ba645 | 2022-09-06 15:57:47 +0300 | [diff] [blame] | 31 | |
Paul Sokolovsky | aa6b8ff | 2022-12-28 19:26:14 +0300 | [diff] [blame] | 32 | ssh -o "PubkeyAcceptedKeyTypes +ssh-rsa" -p 29418 -i "$CI_BOT_KEY" "$CI_BOT_USERNAME@$GERRIT_HOST" gerrit \ |
Paul Sokolovsky | b1ba645 | 2022-09-06 15:57:47 +0300 | [diff] [blame] | 33 | review "$GERRIT_CHANGE_NUMBER,$GERRIT_PATCHSET_NUMBER" \ |
| 34 | --message "$quoted" |
| 35 | fi |