Setting Up GitLab and Jenkins for CI/CD Integration
Installing GitLab
Obtaining GitLab Package
Download the appropriate GitLab CE package from the Tsinghua University Open Source Mirror site:
Index of /gitlab-ce/yum/el7/
Instaling Prerequisites
Install required system dependencies:
yum install -y curl policycoreutils-python openssh-server
Enable and start SSH service if not already running:
systemctl enable sshd
systemctl start sshd
For email notification support, install Postfix:
yum install postfix
systemctl enable postfix
systemctl start postfix
GitLab Installation Process
Install the downloaded RPM package:
rpm -ivh gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
Configuration Steps
Edit the main configuration file:
vi /etc/gitlab/gitlab.rb
Set the external URL:
external_url 'http://server-ip:port'
To resolve potential 502 errors due to port conflicts, modify Unicorn port:
unicorn['port'] = 8101
Apply configuration changes:
gitlab-ctl reconfigure
Service management commands:
gitlab-ctl start
gitlab-ctl stop
gitlab-ctl restart
Retrieve initial root password:
cat /etc/gitlab/initial_root_password
Jenkins Setup
Prerequisites: Java JDK, Maven, and Git should be installed.
Download Jenkins WAR file from the official site and start:
nohup java -jar jenkins.war --httpPort=8080 &
SSH Key Configuration
Install SSH utilities:
yum install ssh-copy-id
Generate SSH keys:
ssh-keygen
Distirbute public key to target servers:
ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.1.194
ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.1.196
Test passwordless SSH connection:
ssh root@192.168.1.194