If you’re new to DevOps or CI/CD and want to get started using the tools without having to configure multiple servers or networks, then installing GitLab and Jenkins on the same machine can expedite your configuration and allow you to focus on learning the tools themselves.
Disclaimer: This type of configuration is not recommended for production, but is meant to serve as a first step in learning how to implement CI/CD.
By the end of this post, you will have GitLab and Jenkins installed on the same CentOS 7 server, with GitLab listening on the default HTTP port (80) and Jenkins listening on port 8081.
Afterward, see this post to learn how to automatically trigger a Jenkins build by pushing to a GitLab repository.
Step 1: Install GitLab
Install dependencies and configure the system firewall to allow HTTP/S (although this tutorial will just deal with HTTP):
sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld
Add the GitLab package repository:
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
Install GitLab, passing in the host URL you want to access it from. In our case, it will just be http://localhost (port 80 by default):
sudo EXTERNAL_URL="http://localhost" yum install -y gitlab-ee
Verify installation by going to http://localhost in your web browser. If you encounter an error, make sure there are no other services already listening on port 80. Also, port 8080 should be free as that is the port the internal Unicorn daemon listens on.
Enter in a new password and then sign in as root with the password you just created. You should then see the welcome page:
Step 2: Install Jenkins
Install Java, add the Jenkins package repository, and install Jenkins:
sudo yum install java-1.8.0-openjdk-devel -y
curl --silent --location http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo | sudo tee /etc/yum.repos.d/jenkins.repo
sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
sudo yum install jenkins -y
Edit the Jenkins configuration file so that Jenkins listens on port 8081 instead of the default 8080:
sudo sed -i 's/JENKINS_PORT="8080"/JENKINS_PORT="8081"/g' /etc/sysconfig/jenkins
Allow port 8081 through the system firewall:
sudo firewall-cmd --permanent --zone=public --add-port=8081/tcp
sudo firewall-cmd --reload
Start the Jenkins service:
sudo systemctl enable jenkins
sudo systemctl start jenkins
In your web browser, go to http://localhost:8081
Copy the administrator password from the specified location and enter it in.
Click Install suggested plugins and wait for the plugins to install.
Create the admin user.
Ensure the Jenkins URL is http://localhost:8081 and click Save and Finish.
Sign in with your new admin credentials and you should see this screen:
Congratulations! You have successfully installed GitLab and Jenkins on CentOS 7. See this post to learn how to configure Jenkins to automatically build Java projects from GitLab.