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 | 3a1f816 | 2022-10-21 18:32:07 +0300 | [diff] [blame] | 12 | # Don't post comments if run on the staging server. |
| 13 | if echo "$JENKINS_URL" | grep -q "ci\.staging"; then |
| 14 | should_post_comment=0 |
| 15 | fi |
| 16 | |
| 17 | # Always enable posting comments to sandbox (test) projects, even if they're |
| 18 | # disabled above. |
Paul Sokolovsky | b1ba645 | 2022-09-06 15:57:47 +0300 | [diff] [blame] | 19 | if echo "${GERRIT_PROJECT}" | grep -q sandbox; then |
| 20 | should_post_comment=1 |
| 21 | fi |
| 22 | |
Paul Sokolovsky | a33efd7 | 2022-12-22 14:28:29 +0300 | [diff] [blame] | 23 | # If run without a patch (e.g. for debugging, don't try to post comment. |
| 24 | if [ -z "$GERRIT_CHANGE_NUMBER" ]; then |
| 25 | should_post_comment=0 |
| 26 | fi |
| 27 | |
Paul Sokolovsky | b1ba645 | 2022-09-06 15:57:47 +0300 | [diff] [blame] | 28 | if [ $should_post_comment -eq 1 ]; then |
| 29 | mkdir -p ~/.ssh/ |
| 30 | ssh-keyscan -H -p 29418 $GERRIT_HOST >> ~/.ssh/known_hosts |
| 31 | |
| 32 | quoted="$(python3 -c 'import sys, shlex; print(shlex.quote(open(sys.argv[1]).read()))' misra_delta.txt)" |
| 33 | |
Paul Sokolovsky | e609c3a | 2022-12-28 19:26:14 +0300 | [diff] [blame^] | 34 | 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] | 35 | review "$GERRIT_CHANGE_NUMBER,$GERRIT_PATCHSET_NUMBER" \ |
| 36 | --message "$quoted" |
| 37 | fi |