About how to install and confiure it, please see another article <gerrit + ldap or http>
在shell中執行命令
ssh -p 29418 [email protected]
提示Permission denied (publickey).
Sometime,
can resolve problem, if problem is not lack of public key.
參考http://www.lifeyun.com/code-review-tools-installation-gerrit.html
執行:
ssh-keygen -t rsa
生成公鑰,
查看:
cat ~/.ssh/id_rsa.pub
將個公鑰添加到gerrit中。
進入http://127.0.0.1:8080/,點擊右上角setting,點左側欄SSH Public Keys
再點擊又邊的add key,將公鑰複製到裏面,點擊add提交。
這裏需要注意的是需要複製的字符串是包括cat ~/.ssh/id_rsa.pub命令打印出來的所有內容,即開啓的ssh-sha和結尾的xx@xxx也要一起復制
再次執行
ssh -p 29418 [email protected]
**** Welcome to Gerrit Code Review ****
Hi fengxinfeng, you have successfully connected over SSH.
Unfortunately, interactive shells are disabled.
To clone a hosted Git repository, use:
git clone ssh://fengxinfeng@localhost:29418/REPOSITORY_NAME.git
5. create project
ssh -p 29418 fengxinfeng@localhost gerrit create-project -n fristproject
6. LDAP auth
Here is an example gerrit.config
[gerrit]
basePath = git
canonicalWebUrl = http://10.126.39.248:8080/
[database]
type = H2
database = db/ReviewDB
[auth]
type = LDAP
[ldap]
server = ldaps://ldapserver
username = CN=ldapreader,ou=Service Accounts,OU=_Common,ou=tead,dc=AP,dc=tieto,dc=com
accountBase = DC=AP,DC=tieto,DC=com
groupBase = DC=AP,DC=tieto,DC=com
accountPattern=(&(objectClass=person)(sAMAccountName=${username}))
sslVerify=false
[sendemail]
smtpServer = localhost
[container]
user = gerrit2
javaHome = /usr/lib/jvm/java-6-sun-1.6.0.31/jre
[sshd]
listenAddress = *:29418
[httpd]
listenUrl = http://*:8080/
[cache]
directory = cache
7. install gerrit
sudo adduser gerrit2
sudo su gerrit2
java -jar gerrit.war init -d /path/to/your/gerrit_application_directory
8. Import an existing project
1).
Create a project in web site,
input project name, for example kernel_goldfish
select "Create initial empty commit"
2). list all projects
ssh -p 29418 [email protected] gerrit ls-projects
3). create a new group for the project
group name, "kernel_project_owner"
4). assign privilege for this project
Reference:
refs/heads/*
Push --> Registered Users
Label Code-Review --> kernel_project_owners
Label Verified --> Registered Users
Submit --> kernel_project_owners
5). Import an existing project to the project
get sources:
git clone http://android.googlesource.com/kernel/goldfish.git
cd goldfish
git branch -av
git checkout remotes/origin/android-goldfish-2.6.29
Create a new branch named android-goldfish-2.6.29 in gerrit.
input name: android-goldfish-2.6.29
create it.
$git push ssh://10.126.39.248:29418/kernel_goldfish HEAD:refs/for/android-goldfish-2.6.29
Maybe there is some error like this, continue
! [remote rejected] HEAD -> refs/for/android-goldfish-2.6.29 (no common ancestry)
error: failed to push some refs to 'ssh://10.126.39.248:29418/kernel_goldfish'
cd test
$git clone ssh://[email protected]:29418/kernel_goldfish
$cd kernel_goldfish
$cp <kernel source code> .
$ rm -rf goldfish/.git
$ cp -r goldfish/* .
$ git add -A
$ git commit -a -s
$ git push ssh://10.126.39.248:29418/kernel_goldfish HEAD:refs/for/android-goldfish-2.6.29
These steps for 5 is a bit complex, maybe there is some easy way, try it when free time.
6). in gerrit, review and submit it.
9. some configuration.
git clone ssh://[email protected]:29418/first.git --no-checkout
git config remote.origin.push refs/heads/*:refs/for/* //will modify .git/config
git config remote.origin.push HEAD:refs/for/master
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
echo Hello > readme.txt
git add readme.txt
git commit -m "Initial commit"
git push origin
git push origin HEAD:refs/for/master
10.
If you want to build another project as same as this, there is a easy way.
you can found command line like this in gerrit review page,
git fetch ssh://[email protected]:29418/goldfish_kernel refs/changes/06/6/1 && git cherry-pick FETCH_HEAD
git push ssh://10.126.39.129:29418/kernel_goldfish HEAD:refs/for/android-goldfish-2.6.29