CLI tool and Python API wrapper for Gerrit Code Review
-
Clone
python-gerritclientrepository:git clone https://github.com/tivaliy/python-gerritclient.git. -
Configure
settings.yamlfile (ingerritclient/settings.yaml) to meet your requirements.url: http://review.example.com auth_type: basic username: admin password: "1234567890aaWmmflSl+ZlOPs23Dffn"
urlcan be specified according to the following format<scheme>://<host>:<port>, e.g.https://review.openstack.orgauth_typespecifies HTTP authentication scheme (basicordigest), can be omitted, then all requests will be anonymous with respective restrictionsusernameandpassword- user credentials from Gerrit system (Settings → HTTP Password)
-
Create isolated Python environment
virtualenv gerritclient_venvand activate itsource gerritclient_venv/bin/activate. -
Install
python-gerritclientwith 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
gerritcommand with required options, e.g.gerrit plugin list. To see all available commands rungerrit --help.
- Clone
python-gerritclientrepository:git clone https://github.com/tivaliy/python-gerritclient.git. - Create isolated Python environment
virtualenv gerritclient_venvand activate itsource gerritclient_venv/bin/activate. - Install
python-gerritclientwith 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