How to Install Jenkins on CentOS 7 and Integrate with GitLab
Jenkins is a popular open-source tool used for continuous integration (CI) and continuous delivery (CD). Written in Java, Jenkins provides a powerful way to automate build, test, and deployment processes. This article will guide you through the steps to install Jenkins on CentOS 7, configure it for integration with GitLab, and establish an efficient CI/CD pipeline.

Why Jenkins is Crucial for CI/CD
Continuous Integration (CI) and Continuous Delivery (CD) practices are essential in modern software development. Jenkins simplifies these practices by automating various tasks, such as building and testing code, which allows developers to focus on creating new features.
Jenkins is a key player in automating code deployments and ensuring that changes are integrated smoothly into a shared repository. With Jenkins, developers can detect issues early in the development process, reducing the chances of breaking the nightly build—a critical aspect of maintaining software quality.
At the same time, Jenkins doesn’t eliminate the need for manual scripting for individual tasks. However, it offers a faster, more efficient approach to integrating your build, test, and deployment workflows compared to building everything from scratch.
Step-by-Step Guide to Install Jenkins on CentOS 7
Step 1: Add the Jenkins Repository
Jenkins is not available in the default CentOS 7 repositories. Therefore, you’ll need to add the Jenkins repository manually. To do this, run the following commands:
[root@jenkins ~]# wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat-stable/jenkins.repo
[root@jenkins ~]# rpm --import http://pkg.jenkins.io/redhat-stable/jenkins.io.key
Step 2: Install Jenkins and Java
To run Jenkins, you’ll also need to install Java. Run the following command to install both Jenkins and the Java Development Kit:
[root@Jenkins ~]# yum install jenkins java-1.8.0-openjdk -y
Step 3: Start and Enable Jenkins Service
Once Jenkins and Java are installed, you can start Jenkins and enable it to start automatically at boot time:
[root@jenkins ~]# systemctl start jenkins
[root@jenkins ~]# systemctl enable jenkins
Step 4: Open Jenkins Ports in the Firewall
If your firewall is enabled on CentOS 7, you’ll need to open the necessary ports to allow Jenkins access. Run the following commands:
[root@jenkins ~]# firewall-cmd --zone=public --add-port=8080/tcp --permanent
[root@jenkins ~]# firewall-cmd --zone=public --add-service=http --permanent
[root@jenkins ~]# firewall-cmd --reload
Step 5: Access the Jenkins Web Interface
Now, open your browser and go to http://<your-server-ip>:8080 to access the Jenkins setup page. The setup wizard will ask you for an admin password. To retrieve it, run:
[root@jenkins ~]# cat /var/log/jenkins/jenkins.log | grep -A 5 password
Copy the password and paste it in the web interface to proceed. Follow the prompts to install the suggested plugins and create an admin user.
Integrating GitLab with Install Jenkins on CentOS 7
After installing Jenkins, you can enhance its functionality by integrating it with GitLab. This integration enables Jenkins to automatically trigger builds whenever a code commit is made in GitLab.
Step 1: Install the GitLab Plugin in Jenkins
- Navigate to Manage Jenkins > Manage Plugins.
- In the Available tab, search for the GitLab plugins: GitLab, GitLab API, GitLab Authentication, and GitLab Hook.
- Select all the relevant plugins and click Install without restart.
Step 2: Configure GitLab Webhook in Jenkins
- In Jenkins, go to New Item and select Freestyle Project. Give it a name and click OK.
- Under the Build Triggers section, select Build when a change is pushed to GitLab.
- Copy the Jenkins webhook URL provided in the settings.
- Log in to GitLab and go to your repository’s Settings > Integrations > Webhook.
- Paste the Jenkins webhook URL and generate a secret token.
- In Jenkins, apply and save the changes. In GitLab, click Test to verify the webhook is working.
Once set up, Jenkins will automatically trigger a build every time new code is committed to your GitLab repository.
Continuous Integration and Continuous Delivery (CI/CD) Explained
What is Continuous Integration (CI)?
CI involves developers frequently committing their code to a shared repository. Each commit triggers an automated build and test process, allowing teams to identify issues early. Tools like Jenkins, Travis CI, and CircleCI are commonly used for CI.
What is Continuous Delivery (CD)?
CD ensures that code is always in a deployable state. By automating the release process, teams can quickly push updates, new features, and bug fixes into production without compromising quality. Popular CD tools include Jenkins, AWS CodeDeploy, and GoCD.
Configuration Management Tools to Enhance Jenkins Workflows
In addition to Jenkins, several configuration management tools can further streamline your CI/CD pipeline:
- Terraform: An open-source tool that manages infrastructure as code. It allows teams to codify infrastructure setups and share them as versioned files.
- Ansible: Automates provisioning, deployment, and configuration management tasks, simplifying cloud infrastructure management.
- SaltStack: A highly scalable configuration management tool that enables the automation of server tasks.
For more advanced solutions, ZippyOPS offers consulting and managed services that encompass a range of technologies like DevOps, Cloud, and AIOps, which can integrate seamlessly with your Jenkins setup.
Conclusion for Install Jenkins on CentOS 7
Installing Jenkins on CentOS 7 and integrating it with GitLab is an excellent way to automate and streamline your development workflow. With Jenkins, you can ensure that your code is built, tested, and deployed efficiently, minimizing the risk of errors and enhancing the quality of your software. To take your CI/CD processes even further, consider using advanced tools like ZippyOPS for DevOps, DataOps, and other managed services that will help optimize your automation pipeline.
If you need assistance with setting up Jenkins, configuring your CI/CD pipeline, or enhancing your software development operations, contact ZippyOPS today for expert consulting and managed services at sales@zippyops.com.



