分类: 项目管理
2011-06-03 09:46:41
If you would prefer to build Gerrit directly from source, review the notes under developer setup. (http://gerrit.googlecode.com/svn/documentation/2.1.6/dev-readme.html)
You can prepare the following required package in case they can not be downloaded at setup time. copy them to /review_site/lib/
During init Gerrit supports: embeded H2, PostgreSQL, MySQL.(During init Gerrit will automatically configure the embedded H2 database. No additional configuration is necessary. Using the embedded H2 database is the easiest way to get a Gerrit site up and running.)
Create a user for the web application within the database, assign it a password, create a database, and give the newly created user full rights on it:
If you do not have mysql installed, use "sudo yum install mysql mysql-server mysql-libs mysql-devel", "service mysqld start", "mysqladmin -u root password '' " to install on rhel.
=== mysql
Initialize a new site directory by running the init command, passing the path of the site directory to be created as an argument to the -d option. Its recommended that Gerrit Code Review be given its own user account on the host system:
Before you install gerrit, make sure your network works (need http_proxy?), or you download mysql driver and bcprov first and copy to lib directory after setup.
Now that you've reached this point you'll have Gerrit running a web application on port 8080, and listening for SSH connections on port 29418, congratulations! You're most of the way there
To Start/Stop/Restart Gerrit site:
To control the Gerrit Code Review daemon that is running in the background, use the rc.d style start script created by init:
(Optional) Link the gerrit.sh script into rc3.d so the daemon automatically starts and stops with the operating system:
To install Gerrit into an existing servlet container instead of using the embedded Jetty server, see J2EE installation.[http://gerrit.googlecode.com/svn/documentation/2.1.6/install-j2ee.html]
All Git repositories under gerrit.basePath must be registered in the Gerrit database in order to be accessed through SSH, or through the web interface.[http://gerrit.googlecode.com/svn/documentation/2.1.6/project-setup.html]
From now on, you can start a project and code review from your workplace.
SSH configurationEach user uploading changes to Gerrit must configure one or more SSH public keys. The per-user SSH key list can be accessed over the web within Gerrit by Settings, and then accessing the SSH Keys tab.
At your client side, following the steps to create ssh public keys.
Then copy the content of the public key file onto your clipboard, and paste it into Gerrit's web interface:
Testing connection(To verify your SSH key is working correctly, try using an SSH client to connect to Gerrit's SSHD port.)
In the command above, sshusername was configured on the SSH Keys tab of the Settings screen. like the user name you use in gerrit, e.g. roger.
Creating users and groups First thing you should do after starting Gerrit up is log in to make sure your user is the administrator.
After logging in with your favorite openID provider, Gerrit will allow you to enter in information about you (SSH key, email address, etc). It's worth noting that the email address is very important as Gerrit uses the email address to match your commits to your Gerrit account.
When you create your SSH key for Gerrit, it's recommended that you give it a custom entry in ~/.ssh/config along the lines of:
Let's create a group for "integrators" that are responsible for reviewing code and integrating it into the "official" repository (typically integrators are project maintainers or core developers). Be sure to add yourself to the "Integrators" group, we'll use this "Integrators" group later to create more granular permissions on a particular project:
configure the gerrit web group rights as follows:
Creating a new repository over SSH is perhaps the easiest way to configure a new project:
Notes: make sure the user you use should be in gerrit administrator group. For more, please refer:
http://gerrit.googlecode.com/svn-history/r6114/documentation/2.1.7/error-permission-denied.html
Then visit Admin > Projects and select "appdemo" and edited some of its permissions.
Add a "Remote" for Gerritclone project from gitorious
Gerrit Code Review provides a standard commit-msg hook which can be installed in the local Git repository to automatically create and insert a unique Change-Id line during git commit. To install the hook, copy it from Gerrit's SSH daemon:
Return to Git repository and add a "remote" for Gerrit, and push my master branch to it, This will give Gerrit a baseline for reviewing changes against and allow it to determine when a change has been merged down.(Here git.myserver.com is the gerrithost)
If you can not do git push because of publickey problem, jump down to the following section for resolution method.
Create a branch and work on that branch and push for code review The last command will push your commit to Gerrit. After the push is complete however, your changes will be awaiting review in Gerrit.
Notes: When do ‘git push’, it always report protocol error(expected sha/ref);
Then I changed the .git/config file to point the url of the repository using another way , it reports ‘Permission denied’ problem (publickey);
I tried to ssh-genkey and copy and save the key to gitorious, it still reports this error, I changed .git/config to point the url to ssh://git.myserver.com/appdemo.git, run ‘git push git.myserver.com HEAD:refs/for/master’, it reports: “you are not commiter” problem;
Then I run “git config –global user.email ” to set user, it still not works, finally I found that we have to configure the gerrit web group rights as follows:
Forge Identity
Administrators
refs/* +2: Forge Committer or Tagger Identity
At this point, you'd likely wait for another reviewer to come along and either comment your code inline in the side-by-side viewer or otherwise approve the commit bu clicking "Publish Comments"
Gerrit contains a number of nice subtle features, like double-clicking a line inside the side-by-side diff to add a comment to that line specifically, the ability to "star" changes (similar to bookmarking) and a too many others to go into detail in this post.
After comments have been published, the view in My Dashboard has changed to indicate that the change has not only been reviewed but also verified.
Upon seeing this, I can return back to my Git repository and feel comfortable merging my code to the master branch:
The last command is significant again, by pushing the updated master branch to Gerrit, we indicate that the change has been merged. Remember to add your ssh key to gitorious.
How to use gerrit-trigger with jenkinsGerrit Trigger Plugin integrates Hudson to Gerrit code review for triggering builds when a "patch set" is created.
(1).Download Gerrit Trigger from the website below:
You wil download a file named gerrit-trigger.hpi .
(2). Goto jenkins->Manage Jenkins->Manage Plugins->Advanced>Update plugins->Browse->Choose gerrit trigger plugin(gerrit-trigger.hpi)->Upload to install.
(3). Goto jenkins->Manage Jenkins ->Gerrit Trigger->Configure Gerrit Server as follows: (we use "jenkins" as the default user to do jenkins jobs) ->Test connections->save->click "start" in control panel.
(3). Create a new job, like "GerritTriggerJob", of cause you can name it according to the project name. Configure the job as normal, and pay attention to the following options related to gerrit and git:
Builder Trigger: Gerrit Event
[Gerrit Trigger]
Gerrit Project: Type: plain; Pattern: appdemo;
Branches: Type: plain; Pattern: master
[Git repository]
URL of repository: ssh://gerrithost/appdemo.git
Refspec (blank to create default): $GERRIT_REFSPEC
Config user.name Value:
Config user.email Value:
Choosing strategy: Gerrit Trigger
(4). Modify codes and commit to gerrit host
(5). Check if you can trigger jobs manually? Jenkins->Query and Trigger Gerrit Patches>search by change id->Trigger selected
(6). Modify codes and commit to gerrit host and see if the created job in jenkins is triggered automatically.
git plugin download:
Refer posts: http://gerrit.googlecode.com/svn/documentation/2.1.6/install.html
http://unethicalblogger.com/node/241