Recently I had to build a new development team within a large company. As part of it, had to implement best practices and processes for the development team. The challenge was to find tools, frameworks, and processes that are critical to the productivity and agility of the team as well as to work with the existing infrastructure, frameworks and tools within the organization. During the course of this, I had to select a code review tool and evaluated a number of them:
Import project
- Crucible
- Review Board
- Phabricator
- Gerrit
Install Gerrit
Install the server with all the defaultsjava -jar gerrit.war init -d ~/gerrit-server
Setup User
By default, Gerrit will be installed with OpenID. Login into Gerrit UI using any authentication (e.g. Google). The first user to login will be added to the Administrator group.- Create SSH Keys
- Login to Gerrit UI and copy the key generated in the previous step (e.g. id_rsa.pub) into your Account Setup
- Setup a username to connect to Git Server hosted by the Gerrit (e.g. gerrit-user)
- Test connectivity from your local client to Gerrit Server
ssh gerrit-user@gerrit-server -p 29418
This will give a nice welcome message and inform that interactive shells are disabled
Import and existing project
To import an existing project, create a new project in Gerrit Server and then run import.- Create a new project called gerrit-test
ssh -p 29418 gerrit-user@gerrit-server gerrit create-project --name gerrit-test
- Create access to gerrit-user to newly created project gerrit-test
- Log into Gerrit UI and create a new user group called gerrit-test-group
- Go to Projects->List->gerrit-test->Access
- Grant access to refs/* for Create Reference permission to user group gerrit-test-group
cd dev/gerrit-test push ssh://gerrit-user@gerrit-server:29418/gerrit-test *:*
Setup local Git Repo for Gerrit
Install Gerrit hookscd dev/gerrit-test scp -p -P 29418 gerrit-user@gerrit-server:hooks/commit-msg .git/hooks
Setup Gerrit server replication to push changes to central repository
- Setup the local ssh keys to connect to the Git server
- Setup the key for git host
git-server> ssh-keygen -t rsa git-host >> ~/.ssh/known_hosts
- Add a new file called replication.config in the gerrit/etc directory with the following contents
[remote "central-git-repo"] url = git@git-host:/{name}.git
- Shutdown and restart the Gerrit Server
Test
- Make some changes in to a local file
- Commit the changes
- Push the changes to Gerrit
git push ssh://gerrit-user@gerrit-server:29418/gerrit-test HEAD:refs/for/master
- Login to Gerrit UI
- Approve the changes with +2
- Gerrit will push the changes to the master git repository. Verify the latest changes are indeed replicated by Gerrit Server
0 comments:
Post a Comment