Gitlab installation

Part reference from the Dark Horse Programmer Java tutorial to automate Deploying Jenkins from environment configuration to project development

Introduction to the

GitLab is an open source project for a repository management system that uses Git as a code management tool and builds a Web service based on it.

Like GitHub, GitLab is a third-party git-based work. It is free and open source (based on the MIT protocol). Like GitHub, you can register as a user, submit your code, add sshkeys, and so on. The difference is that GitLab can be deployed on its own server, and all the information such as database is in its own hands, which is suitable for internal team collaboration development. You can’t always put the wisdom of the team on someone else’s server, can you? In short, think of GitLab as a personal version of GitHub.

The related configuration

  • Installation-related Dependencies
 yum -y install policycoreutils openssh-server openssh-clients postfix
Copy the code
  • Starting the SSH service & Set the SSH service to start upon startup
 systemctl enable sshd && sudo systemctl start sshd
Copy the code
  • Set PostFix to start and start upon startup. Postfix supports GitLab sending
 systemctl enable postfix && systemctl start postfix
Copy the code
  • Open SSH and HTTP services, and then reload the firewall list
 firewall-cmd --add-service=ssh --permanent
 firewall-cmd --add-service=http --permanent
 firewall-cmd --reload
Copy the code

If the firewall is disabled, you do not need to perform the preceding configuration

The installation

Download the GitLab package and install it

Download the installation package online:

Wget HTTP: / / https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/gitlab-ce-12.4.2-ce.0.el6.xCopy the code

The installation

The RPM -i gitlab - ce - 12.4.2 - ce. 0. El6. X86_64. RPMCopy the code

Modify gitLab configuration

Configuration file in/opt/gitlab/etc/gitlab rb

Example Modify the nginx port

 vim /opt/gitlab/etc/gitlab.rb
Copy the code

Modify gitlab access address and port, default is 80, we changed to 82, remember to delete the comment

 external_url 'http://ip:82'
 nginx['listen_port'] = 82
Copy the code

Add the port to the firewall

Firewall -cmd --zone=public --add-port=82/ TCP --permanent firewall-cmd --reloadCopy the code

Modify the Unicorn port

Also in the Gitlab configuration file

 vim /opt/gitlab/etc/gitlab.rb
Copy the code

Change the unicorn port to 8080 by default and delete the comments

## Advanced Settings unicorn['listen'] = '127.0.0.1' unicorn['port'] = desired portCopy the code

Reload the configuration and restart Gitlab

 gitlab-ctl reconfigure
 gitlab-ctl restart
Copy the code

successful

use

The default user name and password are root. You need to change the password the first time you log in

Create a group

Use the root administrator to create a group, a group can have multiple project branches, you can add development to the group to set permissions, different groups are different development projects or service modules of the company, different groups add different development can achieve the management of development permissions

  • Fill in the information and select private mode

  • To create a project, click New Project.

  • Fill in the project information

  • Successfully created

Create a user

  • You can see that there is now only one administrator account

  • Configure user information and select Regular access rights

  • Change password

Add a user to a group

  • Enter the project, select the user to be added, and select user rights

Gitlab users have 5 different permissions within the group:

  • Guest: You can create issues and post comments, but cannot read or write the repository
  • Reporter: Code can be cloned, but not submitted. QA and PM can grant this permission
  • Developer: Can clone code, develop, submit, push, normal development can grant this permission
  • Maintainer: Core developers grant this permission to create projects, add tags, protect branches, add project members, and edit projects
  • Owner: You can set the project access permission – Visibility Level, delete a project, migrate a project, and manage group members. The Owner of the development group can grant this permission

SSH Key Configuration

Schematic diagram of SSH login without password

  • Generate the public and private keys on the Jenkins server using the root user
 ssh-keygen -t rsa -C "your name".
Copy the code

Press enter and use the default value. You do not need to set a password.

Id_rsa: private key file

Id_rsa. pub: public key file

  • Put the generated public key in Gitlab

    Copy the contents of id_rsa.pub as user root and click “Add Key”.

  • Add credentials to Jenkins and configure the private key

    Add a new credential in Jenkins with type “SSH Username with private key” and copy the contents of the generated private file

Successful. Now we can submit the code to the GitLab repository. Jenkins can also pull the code from GitLab to build by_ Aries