blob: 8682e68b9948bef5a712dd202ad58984a6226b78 [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 Sokolovsky73717982022-12-28 19:51:47 +030012# Directory where this script resides.
13SCRIPT_DIR="$(cd "$(dirname "$0")" ; echo "${PWD}")"
14
Paul Sokolovsky3a1f8162022-10-21 18:32:07 +030015# Don't post comments if run on the staging server.
Saheer Babubdb0d652025-02-10 14:08:20 +000016if echo "$JENKINS_PUBLIC_URL" | grep -q "ci\.staging"; then
Paul Sokolovsky3a1f8162022-10-21 18:32:07 +030017 should_post_comment=0
18fi
19
20# Always enable posting comments to sandbox (test) projects, even if they're
21# disabled above.
Paul Sokolovskyb1ba6452022-09-06 15:57:47 +030022if echo "${GERRIT_PROJECT}" | grep -q sandbox; then
23 should_post_comment=1
24fi
25
26if [ $should_post_comment -eq 1 ]; then
27 mkdir -p ~/.ssh/
28 ssh-keyscan -H -p 29418 $GERRIT_HOST >> ~/.ssh/known_hosts
29
Paul Sokolovsky73717982022-12-28 19:51:47 +030030 quoted="$(python3 $SCRIPT_DIR/prepare_gerrit_comment.py misra_delta.txt)"
Paul Sokolovskyb1ba6452022-09-06 15:57:47 +030031
Paul Sokolovskyaa6b8ff2022-12-28 19:26:14 +030032 ssh -o "PubkeyAcceptedKeyTypes +ssh-rsa" -p 29418 -i "$CI_BOT_KEY" "$CI_BOT_USERNAME@$GERRIT_HOST" gerrit \
Paul Sokolovskyb1ba6452022-09-06 15:57:47 +030033 review "$GERRIT_CHANGE_NUMBER,$GERRIT_PATCHSET_NUMBER" \
34 --message "$quoted"
35fi