0

I am looking for a CLI solution for adding a comment to a set of gerrit review returned by using its query interface.

Imagine that I have query string like "project:foobar branch:obsoleted status:open" and I want to notify all users to abandon their CR and raise them against the new branch.

How can I do this?

A bash or python solution would be desirable, if possible.

sorin
  • 161,544
  • 178
  • 535
  • 806

1 Answers1

0

The following script adds a comment in every change found using the restriction you've provided:

changes=$(curl -s --user USER:PASS --request GET https://GERRIT-SERVER/changes/?q=project:PROJECT+AND+branch:BRANCH+AND+status:open | sed 1d | jq --raw-output ".[]._number")

for c in $changes
do
    curl -s --user USER:PASS --request GET https://GERRIT-SERVER/changes/$c/revisions/current/review <<EOF
{
    "message": "COMMENT"
}
EOF
done