From: Aric Gardner Date: Tue, 2 Apr 2019 18:28:57 +0000 (-0400) Subject: Add comment-to-gerrit macro X-Git-Tag: v0.35.0~2 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=b2e2b5b7d3bb61ee9886debb4e010769c35be398;p=releng%2Fglobal-jjb.git Add comment-to-gerrit macro This macro will post a comment to the gerrit patchset if the build creates a file named gerrit_comment.txt To use this macro add it to the list of builders Change-Id: I30e2b10fc4e09f534b161dd99775d66bdc4c3e1a Signed-off-by: Aric Gardner --- diff --git a/docs/jjb/lf-macros.rst b/docs/jjb/lf-macros.rst index 94fcb1c5..bd2b78ff 100644 --- a/docs/jjb/lf-macros.rst +++ b/docs/jjb/lf-macros.rst @@ -5,6 +5,14 @@ Global Macros Builders ======== +comment-to-gerrit +----------------- + +This macro will post a comment to the gerrit patchset if the build +creates a file named gerrit_comment.txt +To use this macro add it to the list of builders. + + lf-fetch-dependent-patches -------------------------- diff --git a/jjb/lf-macros.yaml b/jjb/lf-macros.yaml index 6b3faa85..44bd3859 100644 --- a/jjb/lf-macros.yaml +++ b/jjb/lf-macros.yaml @@ -3,6 +3,14 @@ # BUILDERS # ############ +# To take advantage of this macro, have your build write +# out the file 'gerrit_comment.txt' with information to post +# back to gerrit and include this macro in the list of builders. +- builder: + name: comment-to-gerrit + builders: + - shell: !include-raw ../shell/comment-to-gerrit.sh + - builder: name: lf-fetch-dependent-patches builders: diff --git a/shell/comment-to-gerrit.sh b/shell/comment-to-gerrit.sh new file mode 100644 index 00000000..b4d3d66a --- /dev/null +++ b/shell/comment-to-gerrit.sh @@ -0,0 +1,25 @@ +#!/bin/bash -l +# SPDX-License-Identifier: EPL-1.0 +############################################################################## +# Copyright (c) 2019 The Linux Foundation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +############################################################################## + +set -xe -o pipefail + +if [[ -e gerrit_comment.txt ]] ; then + echo + echo "posting review comment to gerrit..." + echo + cat gerrit_comment.txt + echo + ssh -p 29418 "$GERRIT_HOST" \ + "gerrit review -p $GERRIT_PROJECT \ + -m '$(cat gerrit_comment.txt)' \ + $GERRIT_PATCHSET_REVISION \ + --notify NONE" +fi