OpenStack : Git Gerrit and Jenkins Workflow
Gerrit Workflow
Git Account Setup
You’ll need a Launchpad account, since this is how the Web interface for the Gerrit Code Review system will identify you. This is also useful for automatically crediting bug fixes to you when you address them with your code commits.
If you haven’t already, join The OpenStack Foundation (it’s free and required for all code contributors). Among other privileges, this also allows you to vote in elections and run for elected positions within The OpenStack Project. When signing up for Foundation Membership, make sure to give the same E-mail address you’ll use for code contributions, since this will need to match your preferred E-mail address in Gerrit.
Visit https://review.openstack.org/ and click the Sign In link at the top-right corner of the page. Log in with your Launchpad ID.
Because Gerrit uses Launchpad OpenID single sign-on, you won’t need a separate password for Gerrit, and once you log in to one of Launchpad, Gerrit, or Jenkins, you won’t have to enter your password for the others.
You’ll also want to upload an SSH key while you’re at it, so that you’ll be able to commit changes for review later.
Ensure that you have run these steps to let git know about your email address:
1 2 |
|
To check your git configuration:
1
|
|
Git Review Installation
We recommend using the “git-review” tool which is a git subcommand that handles all the details of working with Gerrit, the code review system used in OpenStack development. Before you start work, make sure you have git-review installed on your system.
On Ubuntu, MacOSx, or most other Unix-like systems, it is as simple as:
1
|
|
On Ubuntu Precise (12.04) and later, git-review is included in the distribution, so install it as any other package:
1
|
|
On Fedora 16 and later, git-review is included into the distribution, so install it as any other package:
1
|
|
On Fedora 15 and earlier you have to install pip (its package name is python-pip
), then install git-review using pip in a conventional way.
On Red Hat Enterprise Linux, you must first enable the EPEL repository, then install it as any other package:
1
|
|
On openSUSE 12.2 and later, git-review is included in the distribution under the name python-git-review, so install it as any other package:
1
|
|
All of git-review’s interactions with gerrit are sequences of normal git commands. If you want to know more about what it’s doing, just add -v to the options and it will print out all of the commands it’s running.
Project Setup
Clone a project in the usual way, for example:
1
|
|
You may want to ask git-review to configure your project to know about Gerrit at this point. If you don’t, it will do so the first time you submit a change for review, but you probably want to do this ahead of time so the Gerrit Change-Id commit hook gets installed. To do so (again, using Nova as an example):
1 2 |
|
Git-review checks that you can log in to gerrit with your ssh key. It assumes that your gerrit/launchpad user name is the same as the current running user. If that doesn’t work, it asks for your gerrit/launchpad user name. If you don’t remember the user name go to the settings page on gerrit to check it out (it’s not your email address).
Note that you can verify the SSH host keys for review.openstack.org here: https://review.openstack.org/#/settings/ssh-keys
If you get the error “We don’t know where your gerrit is.”, you will need to add a new git remote. The url should be in the error message. Copy that and create the new remote.
1
|
|
In the project directory, you have a .git
hidden directory and a .gitreview
hidden file. You can see them with:
1
|
|
1.4 Normal Workflow
Once your local repository is set up as above, you must use the following workflow.
Make sure you have the latest upstream changes:
1 2 3 |
|
Create a topic branch to hold your work and switch to it. If you are working on a blueprint, name your topic branch bp/BLUEPRINT where BLUEPRINT is the name of a blueprint in launchpad (for example, “bp/authentication”). The general convention when working on bugs is to name the branch bug/BUG-NUMBER (for example, “bug/1234567”). Otherwise, give it a meaningful name because it will show up as the topic for your change in Gerrit.
1
|
|
To generate documentation artifacts, navigate to the directory where the pom.xml file is located for the project and run the following command:
1
|
|
1.4.1 Committing Changes
Git commit messages should start with a short 50 character or less summary in a single paragraph. The following paragraph(s) should explain the change in more detail.
1 2 3 4 |
|
For example:
1 2 3 4 5 6 7 |
|
Note that in most cases the Change-Id line should be automatically added by a Gerrit commit hook that you will want to install. See Project Setup for details on configuring your project for Gerrit. If you already made the commit and the Change-Id was not added, do the Gerrit setup step and run:
1
|
|
The commit hook will automatically add the Change-Id when you finish amending the commit message, even if you don’t actually make any changes.
Make your changes, commit them, and submit them for review:
1 2 |
|
Caution: Do not check in changes on your master branch. Doing so will cause merge commits when you pull new upstream changes, and merge commits will not be accepted by Gerrit.
Prior to checking in make sure that you run “tox”.