2. Gerrit configuration--User Configuration

Source: Internet
Author: User

The previous chapter has set up the Gerrit server, the following describes how to create a Gerrit user, and use user login has been changed to user settings


Environment:

Gerrit server:172.16.206.133

client:172.16.206.129


1. Create a user on the Gerrit server

The Gerrit server uses the HTTP authentication type, and uses httpd to do the reverse proxy, creating the user to use the following command

#cd/home/gerrit2/gerrit/etc

[Email protected] etc]# htpasswd-m passwords user2

New Password:

Re-type New Password:

Adding Password for user user2

Enter the password as prompted (the password is set to 123456) so the account is created. The httpd and Gerrit services do not require a reboot to complete the creation.


2, Login Gerrit user

To access Gerrit with the User2 account you created, enter it in the browser address bar:

http://172.16.206.133:8080

Enter the login account password, account number is user2, password is 123456

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7F/E9/wKioL1cxh72j3sxnAAH_7PqFtdg542.png "title=" p1.png "alt=" Wkiol1cxh72j3sxnaah_7pqftdg542.png "/>


3. Modify Gerrit User Configuration

After logging in, click on your username in the top right corner of the webpage and click "Settings".

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7F/E4/wKioL1cxT6yh3itBAABV-Z3w2RA103.png "title=" p2.png "alt=" Wkiol1cxt6yh3itbaabv-z3w2ra103.png "/>

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7F/E6/wKiom1cxTvyDOGa1AAIQnIKspGE990.png "title=" p3.png "alt=" Wkiom1cxtvydoga1aaiqnikspge990.png "/>settings is the user's configuration related information, need to register the mailbox and the public key on the submission server

1. Submit the Public key

Note: Why should I submit a public key file to the Gerrit server? If you do not commit the public key, you cannot use the git push command to submit local code to the Gerrit server. A public key is an authentication method.

Create a public and private key pair on the client 172.16.206.129 this server, with the following commands:

[[email protected] root]$ ssh-keygen -t rsa generating public/private  Rsa key pair. enter file in which to save the key  (/HOME/USER2/.SSH/ID_RSA):  created directory  '/home/user2/.ssh '. enter passphrase  (empty for no passphrase):  enter same passphrase  again: your identification has been saved in /home/user2/.ssh/id_rsa. Your public key has been saved in /home/user2/.ssh/id_rsa.pub.the key  fingerprint is:fd:da:fa:c5:ec:6c:82:60:1f:39:15:bc:62:ec:51:15 [email protected]The  Key ' s randomart image is:+--[ rsa 2048]----+|            . . e. | |             +    | |          . . o   | |          .= o    | |         so.=     | |         o =. o   | |        . o +. +  | |           oo.+.  | |           ooooo  |+-----------------+

The resulting key file is as follows:

[[email protected] ~]$ ls. ssh/

Id_rsa id_rsa.pub

Id_rsa.pub as a public key file, copy and paste the contents of the file into the settings==>ssh. Keys, and click Add

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7F/E4/wKioL1cxUgfDFUVqAAGq3q-4bWk295.png "title=" p4.png "alt=" Wkiol1cxugfdfuvqaagq3q-4bwk295.png "/>

To test if the SSH key is committed successfully, execute the following command on the client 172.16.206.129 server:

#ssh-P 29418 [email protected]

29418 for Gerrit on the SSH server listening port, user2 for the login Gerrit account, note here we use which account login Gerrit to use which account test, and the account has been logged into the Gerrit server, and the public key has been uploaded. 172.16.206.133 is the IP of the Gerrit server

[[email protected] .ssh]$ ssh -p 29418 [email protected]the  authenticity of host  ' [172.16.206.133]:29418  ([172.16.206.133]:29418) '  can ' T be  established. rsa key fingerprint is 93:d3:47:c2:15:32:f0:41:d9:e6:7f:88:66:01:f3:9b. are you sure you want to continue connecting  (yes/no)?  yesWarning : permanently added  ' [172.16.206.133]:29418 '   (RSA)  to the list of  known hosts.  ****    Welcome to Gerrit Code  review    ****  hi user2, you have successfully  Connected over ssh.  unfortunately, interactive shells are disabled.   to clone a hosted git repository, use:  git clone  ssh://[email protected]:29418/repOsitory_name.gitconnection to 172.16.206.133 closed. 

You can see that the connection was successful and that the SSH public key was uploaded successfully.


Register a mailbox for User2

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/7F/E7/wKiom1cxU7GAHRFDAAGEtbEIY_0461.png "title=" p5.png "alt=" Wkiom1cxu7gahrfdaagetbeiy_0461.png "/>

Click Register, login to the mailbox you just registered, activation can be.



4. Create a user group and create a project

Note that only users of the Administrators group can create group and project

Login Gerrit Admin Account admin, create a new group for group2. and add the User2 account to the group

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7F/E4/wKioL1cxVyeQLKvEAAC6XxXWCvc918.png "style=" float: none; "title=" P6.png "alt=" Wkiol1cxvyeqlkveaac6xxxwcvc918.png "/>

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7F/E4/wKioL1cxVyiieK8VAAGaaMumo9Q911.png "style=" float: none; "title=" P7.png "alt=" Wkiol1cxvyiiek8vaagaamumo9q911.png "/>


Create a new project, named Project2

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7F/E4/wKioL1cxWsKynVNDAAICK7gAolU605.png "style=" float: none; "title=" P8.png "alt=" Wkiol1cxwskynvndaaick7gaolu605.png "/>

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7F/E4/wKioL1cxWsWjwjEwAAMaT5CjD8I516.png "style=" float: none; "title=" P10.png "alt=" Wkiol1cxwswjwjewaamat5cjd8i516.png "/>


5. Gerrit Code Review process

The first is the preparation, and the next shows how Gerrit does the code review.


A, the public key of the 172.16.206.129 server is uploaded to the Admin user's ssh in the keys, why the previous upload to the User2 user, here also need to be uploaded to the admin user? Because our project is created by admin admin (only administrators have permission to create). So the user of each project address is admin, take Project2 project as an example:

git clone ssh://admin@172.16.206.133:29418/project2

If the Admin user joins the User2 account to the Administratos group, User2 can also create the project, and the user in the project address is user2. So we need to be from which user the clone project needs to upload the server's public key to which account.


b, client server (172.16.206.129) git initial configuration

Configure user names and mailboxes

#git config--global user.name "User2"

#git config--global user.email "YOUR email-address"


C, clone a project

[[email protected] ~]$ git clone ssh://[email protected]:29418/project2[[email protected] ~]$ Lsproject2[[email Protected] ~] CD Project2


d. copy commit-msg file

Note that if this step is omitted, the following error may be used in the git Push command times

Error:missing Change-id in commit message footer

[[email protected] Project2] $SCP-P-P 29418 [email protected]:hooks/commit-msg./.git/hooks/


Note: C, d Two-step can use the clone with commit-msg hook inside the command to achieve

#git clone Ssh://[email protected]:29418/project2 && scp-p-P 29418 [email protected]:hooks/commit-msg project2/ . git/hooks/

It is often necessary to submit code to the server, you need to use this command, if you do not need to commit code, such as you only need to clone code and compile packaging, you do not need to use this command, and only need to use

git clone ssh://[email protected]: 29418/project2

or git clone http//[email protected]: 8081/a/project2



E. Create a file and submit it to the Gerrit server side

[Email protected] project2]$ vim test.sh AAAAAAAAAAAAABBBBBBBBBBBBBCCCCCCCCCCCCC

Save files to a git repository with git add and git commit commands

[[email protected] project2]$ git add test.sh [[email protected] project2]$ git commit-m "created test.sh file" [Master 16462e9] Gen Built the test.sh file 1 files changed, 3 insertions (+), 0 deletions (-) Create mode 100644 test.sh


Upload code from local to the master branch under the Gerrit Server object project with the git Push command

[[email protected] project2]$ Git push origin master:refs/for/mastercounting objects:4, done. Compressing objects:100% (2/2), done. Writing objects:100% (3/3), 341 bytes, done. Total 3 (delta 0), reused 0 (Delta 0) remote:processing changes:new:1, refs:1, done Remote:remote:New Changes:remo TE:HTTP://172.16.206.133:8081/5 created the test.sh file remote:to ssh://[email protected]:29418/project2 * [New branch] Maste R-Refs/for/master

Origin: The name of the remote repository, using Git remote to view all the remote warehouse names

[[email protected] project2]$ Git remote origin
Master:refs/for/master means that the code is passed from the local master branch to the remote Master Branch, which is the fixed format


F, see if there is code review information on the Gerrit server

Login Gerrit Admin Account admin, click "Open" under all to see the "Create test.sh" record.

Here "created test.sh file" is the git commit-m "created test.sh file" command generated by the

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7F/E6/wKioL1cxd0KC9IBEAAJt4--8EoI491.png "style=" float: none; "title=" Pp1.png "alt=" Wkiol1cxd0kc9ibeaajt4--8eoi491.png "/>

Click on this record to see the following information


650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7F/E6/wKioL1cxd0biNku7AARvdB2TlY4241.png "style=" float: none; "title=" Pp2.png "alt=" Wkiol1cxd0binku7aarvdb2tly4241.png "/>


We can open the test.sh file and see what's inside.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7F/E6/wKioL1cxeGuDJUuNAAEkJvYYuEs066.png "title=" Pp3.png "alt=" Wkiol1cxegudjuunaaekjvyyues066.png "/>


You can also see the submitter's information:

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7F/E6/wKioL1cxeRrASYpkAAEtZeZW_es670.png "title=" Pp4.png "alt=" Wkiol1cxerrasypkaaetzezw_es670.png "/>

The user name and e-mail address shown here are actually the same as when you initialize git on the client server to configure the

#git config--global user.name "User2"

#git config--global user.email "YOUR email-address"


Click on the code review and replay to review

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/7F/E9/wKiom1cxebSB85xGAAEUOX7Xn3A497.png "title=" pp.png "alt=" Wkiom1cxebsb85xgaaeuox7xn3a497.png "/>-2 said not to pass, +2 means that code OK can pass the audit, not yet delve into this, I understand this is the case."

Audit logs can be seen after auditing

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7F/E7/wKioL1cxe1iyH_XTAAEcFP-mH0E976.png "title=" Pp5.png "alt=" Wkiol1cxe1iyh_xtaaecfp-mh0e976.png "/>


The above is the Gerrit code review process, Gerrit Warehouse is a purely code warehouse, there is no work tree this argument. Therefore, executing the git command in the Gerrit repository will result in an error:

[[email protected] project2.git]# git statusfatal:this operation must be run in a work tree

However, if you clone the project inside the Gerrit repository with Git clone, it will automatically become a git repository.


PS: I am the operation of the reform hand, many things have not had time to learn to understand, if the article has the wrong place please forgive me.


For git-related knowledge, please refer to: https://git-scm.com/book/zh/v2/

For Gerrit related knowledge, please refer to the official documentation:

Http://gerrit-documentation.googlecode.com/svn/Documentation/2.5/intro-quick.html



This article from "Zengestudy" blog, declined reprint!

2. Gerrit configuration--User Configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.