blob: ec83e9e6690a96bde8028f72b4108590a8c4bfb1 [file] [log] [blame]
Paul Sokolovskyb1ba6452022-09-06 15:57:47 +03001#!/bin/bash
2#
Paul Sokolovsky3a1f8162022-10-21 18:32:07 +03003# Copyright (c) 2019-2022, Arm Limited. All rights reserved.
Paul Sokolovskyb1ba6452022-09-06 15:57:47 +03004#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7set -ex
8
Paul Sokolovsky3a1f8162022-10-21 18:32:07 +03009# Set to 0 to temporarily disable posting comments to Gerrit.
10should_post_comment=1
Paul Sokolovskyb1ba6452022-09-06 15:57:47 +030011
Paul Sokolovsky3a1f8162022-10-21 18:32:07 +030012# Don't post comments if run on the staging server.
13if echo "$JENKINS_URL" | grep -q "ci\.staging"; then
14 should_post_comment=0
15fi
16
17# Always enable posting comments to sandbox (test) projects, even if they're
18# disabled above.
Paul Sokolovskyb1ba6452022-09-06 15:57:47 +030019if echo "${GERRIT_PROJECT}" | grep -q sandbox; then
20 should_post_comment=1
21fi
22
23if [ $should_post_comment -eq 1 ]; then
24 mkdir -p ~/.ssh/
25 ssh-keyscan -H -p 29418 $GERRIT_HOST >> ~/.ssh/known_hosts
26
27 quoted="$(python3 -c 'import sys, shlex; print(shlex.quote(open(sys.argv[1]).read()))' misra_delta.txt)"
28
29 ssh -vvvv -o "PubkeyAcceptedKeyTypes +ssh-rsa" -p 29418 -i "$CI_BOT_KEY" "$CI_BOT_USERNAME@$GERRIT_HOST" gerrit \
30 review "$GERRIT_CHANGE_NUMBER,$GERRIT_PATCHSET_NUMBER" \
31 --message "$quoted"
32fi