Git Gerrit and Jenkins

We have switched to Git as SCM. The git repositories are owned by Gerrit, a code review tool, that let us review and verify commits before they make it into the main branches in the repositories. Jenkins is used for the verification of each commit.

Git

Git will be needed to be able to clone the repositories and to push commits for review. Please install the git version of your like.

Gerrit

  1. Go to Gerrit.
  2. To access Gerrit you will need to register with an Open ID account. If you haven't got one, register for a gmail account or on any other place that provide Open ID. We will try to setup swgemu.com to be Open ID as well. Select a username as well since it is needed to access Gerrit over SSH.
  3. Next step is to generate a ssh key and provide Gerrit with the public one. ssh-keygen is normally installed together with the git installation so run that and save the keys in the default location. You can use an already existing key if you like. When you login to Gerrit, go to settings in the top right corner, then select SSH Public Keys in the menu to the left. Paste your key in the text box.
  4. Verify that you have access to Gerrit by connecting with SSH. 'ssh -p 29418 userNameInGerrit@review.swgemu.com'. It should look like the text below. ssh -p 29418 userNameInGerrit@review.swgemu.com **** Welcome to Gerrit Code Review **** Hi , you have successfully connected over SSH. Unfortunately, interactive shells are disabled. To clone a hosted Git repository, use: git clone ssh://userNameInGerrit@review.swgemu.com:29418/REPOSITORY_NAME.git Connection to review.swgemu.com closed.
  5. Now, clone the repositories with the command above. You can look up the repository names on Gerrit -> Projects -> List (More details in this step later when the repositories are available). git clone ssh://userNameInGerrit@review.swgemu.com:29418/Core3.git
    git clone ssh://userNameInGerrit@review.swgemu.com:29418/PublicEngine.git
    git clone ssh://userNameInGerrit@review.swgemu.com:29418/Tools.git
  6. To be able to commit and push commits for reviews you need to install a commit hook in the git repositories. Do it by running the following command in every repository. scp -p -P 29418 userNameInGerrit@review.swgemu.com:hooks/commit-msg .git/hooks
  7. Create a new branch in git from origin/unstable and commit your changes on that branch. Note that every commit has to compile correctly otherwise Jenkins will reject that commit.
  8. You are now ready to push you first set of commits for review. A pushed set of commits are referred to as a 'patch set' in Gerrit.
  9. To push a patch set push the branch with the changes to Gerrit with the following command: git push origin :refs/for/unstable/

Jenkins

Jenkins will verify each patch set before it is merged to the main branches. The verification will to start with be a verification that everything compiles. To access Jenkins go to the following page: Jenkins. Jenkins will post verification results on you patch sets. If Jenkins verification fails you need to check the specific build referred to in the comments on you patch set and fix the issues. Jenkins will write a verification summary in each commit in the patch set. Jenkins will refer to the build that verified the commit in each message. If Jenkins rejected the commit, check the console output of the build to see why it fails. Fix that commit, it can require you to both amend to the last commit or do a temporary branch in the middle of your patch set and then rebase the branch interactively to merge a new change into an already existing commit. Look for guides on how to use git for a more detailed explanation of amend and rebase.

Eclipse

These steps are only valid after you have created your ssh keys and saved them in gerrit for your user.
  1. Cloning the repository
  2. Pushing a review to gerrit