Sunday, November 25, 2012

Using your gerrit server in eclipse

So you followed the tutorial on how to setup a gerrit server and want to use it with eclipse?  Keep on reading...

We are using eclipse 4.2 here, not sure if all the required egit features are already present in previous versions.

Preparations

Gerrit is configured through its web frontend. As mentioned the first user to login will gain admin rights, so login with your administrator user. On the Projects tab you may Create a New Project.


I'm not going into details on project options here. The default settings should be sufficient for us to commit and review code.

Step 1: Configure a user

Now restart your browser, clear your passwords or do whatever necessary to get the authentication dialog back when accessing gerrit (in Firefox you might start a private session). Login with a user account, in the tutorial here I will use user1. You need to use the password you provided in the htaccess file on your server.

On the righthand side there is a Settings link. Fill in your Contact Information: provide your real name and a valid email address. You will receive a confirmation mail to verify your account.

Next add your SSH Public Key. If you don't have one yet you may create one in eclipse preferences.


Make sure you hit Save Private Key... otherwise your created key would not be saved permanently.

Back to gerrit: as a last step create a HTTP Password.

Every user of your system should follow these steps before he actually may use gerrit.

Step 2: Add gerrit repository in eclipse

The Git Repositories view allows to Clone a Git repository. The wizard will first ask for the repository type, obviously we want Gerrit. On the next page click on Add... and add your gerrit repository location.


The Server address is the same as you just entered in your browser before. Use your User ID and the htaccess file Password. Validate your settings before you hit Finish.

You should see your playground repository now. Gerrit allows to access this repository in multiple ways. We will use http (authorized) access in our example, but anonymous http and ssh will work, too.


Select the master branch and continue the wizard accepting the default settings.

Step 3: Committing & reviewing

Now you can start to share projects the same way as you would do it for git. On your first commit you might change a difference: There is a change ID provided for you:


On your first push you will be asked for credentials. The user name is still user1, but the password is the one you created on the gerrit webpage in your user settings. It is NOT the password from the htaccess file. Make sure you don't mix up those two.

You can see your change in gerrit by now:


Step 4: Mylyn integation

The gerrit web frontend is nice, but fun starts when you use mylyn integration. Unfortunately gerrit 2.5 support seems to be broken in Juno SR1 (see bug 393807). You still can use mylyn if you update your installation using the weeky builds update site: http://download.eclipse.org/mylyn/snapshots/weekly

I updated Mylyn Task List, Mylyn Reviews Connector: Gerrit and Mylyn Versions Connector: Git. Possibly updating the gerrit connector might be sufficient.

Open the Task List view to see pending review tasks. If you don't have defined queries yet you should find an "Unmatched" folder containing an entry for your first import. Now you can directly edit your reviews within eclipse.




No comments:

Post a Comment