This post list the details of some of the important gerrit commands which we have tried, (This post will be updated as and when we use the commands)
Note: The gerrit commands are executed on Ubuntu gerrit review server https://review.opendev.org/ . You may need to register to execute same commands on this server.
Check gerrit version
$ ssh -p GERRIT_PORT -i PATH_TO_SSH_PRIVATE_KEY GERRIT_SERVER_URL gerrit version
Example of this is,
$ ssh -p 29418 -i /home/devlab/.ssh/id_rsa review.opendev.org gerrit version
- “-p” you can change the gerrit port used for ssh authentican.
- “-i ” – specify ssh private key.
Check list of projects from gerrit server
$ ssh -p GERRIT_PORT -i PATH_TO_SSH_PRIVATE_KEY GERRIT_SERVER_URL gerrit ls-projects
$ ssh -p 29418 -i /home/devlab/.ssh/id_rsa review.opendev.org gerrit ls-projects
Get the information from gerrit server
$ ssh -p GERRIT_PORT -i PATH_TO_SSH_PRIVATE_KEY GERRIT_SERVER_URL gerrit query project:{^PROJECT_NAME} --format=JSON --all-approvals --comments --all-reviewers
You can use the project name as obtained using “gerrit ls-projects” command as above to get the information such as approvals, comments, reviews etc in the format of JSON.
$ ssh -p 29418 -i /home/devlab/.ssh/id_rsa review.opendev.org gerrit query project:{^All-Projects} --format=JSON --all-approvals --comments --all-reviewers