http://scmforge.com/?p=1
http://git-scm.com/book/en/Getting-Started-First-Time-Git-Setup
http://www.infoq.com/cn/articles/Gerrit-jenkins-hudson
also based on my trial to setup gerri,git on 64 bit ubuntu server as guest OS of vmware virtual machine runs on 64 bit win 7 host OS
First step – Git installation:
As I use Ubuntu – this task is very simple. Just run one command like below:
root@scmforge:~# sudo apt-get -y install git-core
root@scmforge:~# git --version
git version 1.7.5.4
git setup:
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
Second step – Gerrit installation:
I prefer to use functional accounts for each of services on my servers so first I create gerrit user:root@scmforge:~# adduser gerrit
root@scmforge:~# su - gerrit
gerrit@scmforge:~$
To build Gerrit war package – Maven and some Java JDK is necessary as Gerrit is Java based tool, in my case I used the following command to install both:
root@scmforge:~# apt-get install maven2 openjdk-6-jdk
After gerrit user is already created and all prerequisites to build and run Gerrit are installed – now is the time to get Gerrit sources and prepare executable package:
root@scmforge:~# su - gerrit
wget
http://gerrit.googlecode.com/files/gerrit-2.4.2.wargerrit@scmforge:~$ git clone https://gerrit.googlesource.com/gerrit
Cloning into gerrit...
remote: Counting objects: 60865, done
remote: Finding sources: 100% (60865/60865)
remote: Getting sizes: 100% (22864/22864)
remote: Compressing objects: 100% (22858/22858)
remote: Total 60865 (delta 34139), reused 60677 (delta 34056)
Receiving objects: 100% (60865/60865), 11.74 MiB | 4.36 MiB/s, done.
Resolving deltas: 100% (34237/34237), done.
gerrit@scmforge:~$ cd gerrit/
gerrit@scmforge:~/gerrit$ mvn package
When Maven finished building, WAR file was created in gerrit-war/target/ directory, in my case it was exactly: ./target/gerrit-2.3.war
Some database will be needed (MySQL, PostgreSQL, or simple H2 can be used) so we can create it as usually, by:
postgres=# CREATE ROLE gerrit LOGIN ENCRYPTED PASSWORD 'gerrit' NOINHERIT VALID UNTIL 'infinity';
CREATE ROLE
postgres=# CREATE DATABASE gerrit_playground WITH ENCODING='UTF8' OWNER=gerrit;
CREATE DATABASE
Third step – creating Gerrit environment:
Now we can create playground environment by invoking Gerrit with init parameter and answering few simple questions:
gerrit@scmforge:~$ java -jar gerrit-2.3.war init -d playground
java -jar /home/gerrit/gerrit-2.4.2.war init -d playground
*** Gerrit Code Review 2.3
Create '/home/gerrit/playground' [Y/n]? Y
*** Git Repositories
Location of Git repositories [git]: git
*** SQL Database
Database server type [H2/?]: H2
mysql
*** User Authentication
Authentication method [OPENID/?]: development_become_any_account
*** Email Delivery
SMTP server hostname [localhost]:
SMTP server port [(default)]:
SMTP encryption [NONE/?]:
SMTP username :
*** Container Process
Run as [gerrit]: gerit
Java runtime [/usr/lib/jvm/java-6-openjdk/jre]: /usr/lib/jvm/java-6-openjdk/jre
Copy gerrit.war to /home/gerrit/playground/bin/gerrit.war [Y/n]?
Copying gerrit.war to /home/gerrit/playground/bin/gerrit.war
*** SSH Daemon
Listen on address [*]: *
Listen on port [29418]: 29418
Gerrit Code Review is not shipped with Bouncy Castle Crypto v144
If available, Gerrit can take advantage of features
in the library, but will also function without it.
Download and install it now [Y/n]?
Downloading http://www.bouncycastle.org/download/bcprov-jdk16-144.jar ... OK
Checksum bcprov-jdk16-144.jar OK
Generating SSH host key ... rsa... dsa... done
*** HTTP Daemon
Behind reverse proxy [y/N]? N
Use SSL (https://) [y/N]? N
Listen on address [*]: *
Listen on port [8080]: 8080
Initialized /home/gerrit/playground
Executing /home/gerrit/playground/bin/gerrit.sh start
/home/gerrit/gerrit/playground/bin/gerrit.sh start
Starting Gerrit Code Review: OK
Waiting for server to start ... OK
Opening browser ...
Please open a browser and go to http://scmforge.com:8080/#/admin/projects/
g.s:8080/#/admin/projects/
As I had some serious issues with PostgreSQL connection I chose H2 as backbone database because it was the fastest workaround in my case and I do not need nothing more right now.
After opening suggested URL – I could see the following screen:

“Become” option allows You to create admin user account and look around at all Gerrit functionality (which is not integrated with Git yet). After that You can create Your fist Sandbox project with default settings proposed by Gerrit.
Remember to add Your SSH public key to Your account/settings – without it working with Gerrit is not possible. In Your settings You have to also specify Your Username. (which is actually SSH user)
If all setup is ok, You should be able to see similar server response after trying to log in:
szwed@vaio:~$ ssh -p 29418 szwed@scmforge.com
ssh -p 29418 d68fbe50@g.s
**** Welcome to Gerrit Code Review ****
Hi Piotr Szwed, you have successfully connected over SSH.
Unfortunately, interactive shells are disabled.
To clone a hosted Git repository, use:
git clone ssh://szwed@scmforge.com:29418/REPOSITORY_NAME.git
Connection to scmforge.com closed.
If You have similar results – it means that basic setup is OK and We can jump to the further steps.
Fourth step – Gerrit integration with GIT:
So.. We have already Gerrit setup and working, We have already created first project, our SSH connection is working well – now is the time to clone Sandbox repository and make some test commit. I tried the following waycdszwed@vaio:~$ git clone ssh://szwed@scmforge.com:29418/Sandbox.git
git clone ssh://d68fbe50@g.s:29418/symfonyproject.git
Cloning into 'Sandbox'...
remote: Counting objects: 2, done
remote: Finding sources: 100% (2/2)
remote: Total 2 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (2/2), done.
szwed@vaio:~$ cd Sandbox/
cd symfonyproject
szwed@vaio:~/Sandbox$ echo "Test text." > test.txt
cp -r Symfony/* symfonyproject/
szwed@vaio:~/Sandbox$ git add test.txt
git add .
szwed@vaio:~/Sandbox$ git commit -a -m "First test commit."
git commit -m 'initial symfony project version'
[master 44ca585] First test commit.
Committer: Piotr Szwed <szwed@vaio.(none)>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
1 file changed, 1 insertion(+)
create mode 100644 test.txt
create a group for your project
create a group for your project
go to
g.s:8080/#/admin/projects/
click admin
click groups
click hyperlink Create New Group
enter the name of your project.
e.g.:
symfonyproject
give this group with push permission of your project
give this group with push permission of your project
go to
g.s:8080/#/admin/projects/
click on projects
click on list
click on hyperlink with name of your project
click access
click edit
click on
Add Reference
click on drop down menu with text:Add permission
click on push in that menu
enter the name of group you create
e.g.:
symfonyproject
click add
click Save changes
And push our changes to the Gerrit server:
szwed@vaio:~/Sandbox$ git push ssh://szwed@scmforge.com:29418/Sandbox.git
git push ssh://d68fbe50@g.s:29418/symfonyproject.git
HEAD:refs/for/master
Counting objects: 4, done.
Writing objects: 100% (3/3), 256 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://szwed@scmforge.com:29418/Sandbox.git
* [new branch] HEAD -> refs/for/master
szwed@vaio:~/Sandbox$
After that my change was ready for review as on the picture presented below:

As a result I am able to review and approve the change. Some simple Project groups and access modifications may be needed here as by default Gerrit does not provide useful setup and Workflow.
Now is the time to invite developers and encourage Them to use Gerrit
上述的推送,沒有經過 code review 的流程
採用 code review 流程的推送方式,
需經過以下設定後推送,
「 Gerrit不希望我們直接覆寫Git代碼庫中的任何分支,而是將變更推送到另一個refspec中,這讓Gerrit有機會在代碼審查中修改代碼。最簡單的方法是為推送配置一個默認的refspec:
$ git config remote.origin.push refs/heads/*:refs/for/* $ git push origin」
前段引文,引用自 URL :
http://www.infoq.com/cn/articles/Gerrit-jenkins-hudson
沒有留言:
張貼留言