Table of contents
Five, install and configure gitlab-runner
7. Enable the Pages function in Gitlab
1. Install Git
1. Download address: Index of /pub/software/scm/git/
2. Software version: git-2.9.5.tar.gz
3. Compile the Git version:
4. First install dependencies (the following are all done in the root directory): If the operating system does not have gcc installed during compilation, use yum -y install gcc*
yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
tar -zxvf git-2.9.5.tar.gz
cd git-2.9.5/
make prefix=/usr/local all
make prefix=/usr/local install
5. If you encounter an error, such as:
6. This is because gcc is not installed in CentOS, just install gcc.
Check the installation status:
2. Install Gitlab
1. Download address: https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
2. Software version: gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm
3. Install:
rpm -ivh gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm
4. Modify the gitlab configuration file to specify the server IP and custom port
vim /etc/gitlab/gitlab.rb
5. Reset the gitlab configuration
gitlab-ctl reconfigure
It takes a few minutes to configure, and occasionally it seems to be stuck, so stick to it for a while.
Reminder: linux gitlab-ctl reconfigure error report problem fixes 502
6. Start gitlab
gitlab-ctl start
7. Browser access, http://192.168.56.128:8082/ , access failed, solution
Turn off the firewall:
systemctl status firewalld.service
Or, open the port number of gitlab:
firewall-cmd --zone=public --add-port=端口号/tcp --permanent
Then restart the firewall:
systemctl restart firewalld.service
8. Visit the home page again:
9. Modify the password:
cd /opt/gitlab/bin
sudo gitlab-rails console -e production
user = User.where(id: 1).first
user.password = 'secret_pass'
user.password_confirmation = 'secret_pass'
user.save!
exit
user means the root user,
10. Log in to gitlab root/12345678
3. Configuration items
1. Create a new project
Prompt that we can create a group
2. Create a group: Atlas-dev
3. Set Chinese:
4. Set email reminder
Email on push : Email each pushed commit and diff to a list of recipients.
Pipeline Email : Email pipeline status to multiple recipients.
1. Open the SMTP service of the mailbox:
2. Modify the gitlab configuration
(1) Enter the configuration file
vim /etc/gitlab/gitlab.rb
(2) Modify the configuration file
You can find these contents in the file and modify them. Since these contents are commented, you can also add them directly;
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "4513320Why"
gitlab_rails['smtp_domain'] = "exmail.qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['smtp_pool'] = false
gitlab_rails['gitlab_email_from'] = '[email protected]'
(3) Update settings
gitlab-ctl reconfigure
...
(4) Test whether the mail service is normal
Open the gitlab console ( this step will take a long time to open )
gitlab-rails console
Notify.test_email('接收方邮件地址','邮件标题','邮件内容').deliver_now
Check email:
Five, install and configure gitlab-runner
1. Install gitlab-runner
1. Download the gitlab-runner installation package:
https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/yum/el7-x86_64/gitlab-runner-14.0.0-1.x86_64.rpm
2. Install gitlab-runner
rpm -ivh gitlab-runner-14.0.0-1.x86_64.rpm
3. View gitlab-runner status
4. Create a gitlab-ci user
useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
5. Install and start as a service
sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
2. Register Runner to Gitlab
Runners can be distributed on different hosts, and there can be multiple Runners on the same host.
The relationship between gitlabCI and gitlab-runner
1. Enter the command: You will be asked to enter the url and Token of gitlab. You can find the url and token information on gitlab.
sudo gitlab-runner register
2. View url and token information on gitlab; I want to distinguish here, gitlab can create three runners;
The first type: Specific Runner, specified type. This Runner can only serve the specified project. Anyone with access to the project can create Specific Runners for the project. Its runner information is on the left side of Project --> Settings --> CI/CD --> Runner: Specific runners
The second type: Shared Runner, shared type. This Runner can be used in all projects. Only system administrators can create Shared Runners. Its runner information is the administrator management center -->Runner
The third type: Group runner, group type. This kind of project can be used by projects belonging to the same group, and does not require additional enabling authorization by the administrator. First find my group-->Settings-->CI/CD-->Runner-->Group Runner
3. Create a runner, taking a group runner as an example.
4. Return to the gitlab page to view the group-runner just created
5. Return to the project information, you can see that this group runner is available.
6. Check the group-runner information, which can be modified in the gitlab page.
7. Create a share-runner
8. View the newly created shared runner
Pay special attention to this label , which is very important, because in the .gitlabyml file, the written label must be consistent with the label name set here, otherwise the runner will not be found during construction.
Six, Gitlab-ci error
gitlab-ci-error-during-connect-post-http-docker2375
needs to modify the gitlab-runner configuration file: config.toml, restart gitlab-runner
vim /etc/gitlab-runner/config.toml
privileged = true
volumes = ["/cache", "/var/run/docker.sock:/var/run/docker.sock"]
gitlab-runner restart
7. Enable the Pages function in Gitlab
Modify the configuration file /etc/gitlab/gitlab.rb and write the domain name
pages_external_url "http://域名/"
gitlab_pages['enable'] = true
Restart gitlab after loading configuration
gitlab-ctl reconfigure
gitlab-ctl start
Modify the Maximum size of pages (MB) in Pages to 1024