CLI tool and Python API wrapper for Gerrit Code Review
-
Clone
python-gerritclient
repository:git clone https://github.com/tivaliy/python-gerritclient.git
. -
Configure
settings.yaml
file (ingerritclient/settings.yaml
) to meet your requirements.url: http://review.example.com auth_type: basic username: admin password: "1234567890aaWmmflSl+ZlOPs23Dffn"
url
can be specified according to the following format<scheme>://<host>:<port>
, e.g.https://review.openstack.org
auth_type
specifies HTTP authentication scheme (basic
ordigest
), can be omitted, then all requests will be anonymous with respective restrictionsusername
andpassword
- user credentials from Gerrit system (Settings → HTTP Password)
-
Create isolated Python environment
virtualenv gerritclient_venv
and activate itsource gerritclient_venv/bin/activate
. -
Install
python-gerritclient
with all necessary dependencies:pip install python-gerritclient/.
. -
(Optional) Add gerrit command bash completion
gerrit complete | sudo tee /etc/bash_completion.d/gc.bash_completion > /dev/null
-
Run
gerrit
command with required options, e.g.gerrit plugin list
. To see all available commands rungerrit --help
.
- Clone
python-gerritclient
repository:git clone https://github.com/tivaliy/python-gerritclient.git
. - Create isolated Python environment
virtualenv gerritclient_venv
and activate itsource gerritclient_venv/bin/activate
. - Install
python-gerritclient
with all necessary dependencies:pip install python-gerritclient/.
.
from gerritclient import client
connection = client.connect("review.openstack.org", auth_type="digest" username="user-name", password="password")
group_client = client.get_client('group', connection=connection)
members = group_client.get_group_members('swift-core') # or get_group_members(24)
print(', '.join(member['name'] for member in members))
Output result: Alistair Coles, Christian Schwede, Clay Gerrard, Darrell Bishop, David Goetz, Greg Lange, Janie Richling, John Dickinson, Kota Tsuyuzaki, Mahati Chamarthy, Matthew Oliver, Michael Barton, Pete Zaitcev, Samuel Merritt, Thiago da Silva, Tim Burke