1. Gerrit Create new Project
Admin login Gerrit,project to create a new project with the same project name as the remote git library.
2. Jenkins Configuration
> Configuration Review Jobs
The local git library address that git is configured to Gerrit
Add Gerrit Trigger Configuration
> Configuring remote GIT code base automatic deployment
git configured as remote git library address
Add build triggers: Poll SCM-> H/5 * * *
Add Post Build Action: Execute Shell
3. Add the. Gitreview configuration file in the remote git library
Clone to Local
$git Clone Git@xx.xx.xx.xx:group/project.git
$ CD Project
$ vim. Gitreview
1 2 3 4 |
[Gerrit] host=xx.xx.xx.xx port=29418 project= project.git defaultbranch=develop |
$git Add. Gitreview
$git commit-m "Add. Gitreview"
$git push
4. In Gerrit git directory to delete the original created the project, clone remote Git library
$CD gerrit_home/git
$rm-rf project.git
$git clone--bare git@xx.xx.xx.xx:group/project.git
$git config-- Global User.Name ' Gerrit '
$git config--global user.email ' gerrit_admin_email '
Solve Chinese garbled
$ git config--global core.quotepath false
$ git config--global i18n.logoutputencoding utf8
$ git config--global I18n.commitencoding UTF8
Support Gitweb
$ git config--file/home/gerrit/gerrit_site/etc/gerrit.config gitweb.cgi/var/www/git/gitweb.cgi
$ git config--file/home/gerrit/gerrit_site/etc/gerrit.config--unset gitweb.url
5. Add the remote git library configuration in the Etc/replication.config file
$ vim Etc/replication.config
1 2 3 4 5 6 7 |
[Remote Project] projects = Project URL = git@xx.xx.xx.xx:group/project. git push = +refs/heads/*:refs/heads/* Push = +refs/tags/*:refs/tags/* push = +refs/changes/*:refs/changes/* threads = 3 |
6. Jenkins Webhook
Triggers a remote build in Jenkins, sets the password, and sets the hook Url in the webhook of the Git repository:
Http://xx.xx.xx.xx/buildByToken/build?job=project&token=PASSWORD
7. Add New User
# htpasswd-c/home/gerrit/gerrit_site/etc/passwords Gerrit
8. Run Index