How to install Jenkins on CentOS 7?

0
4379

Continuous integration is a term that can confuse certain people who do not constantly develop applications in a business environment. Jenkins is the software that makes it possible. So, in this tutorial, I will show you how to install Jenkins on CentOS 7.

Jenkins is an open source automation server, that provides hundreds of plugins to support building, deploying and automating any project. I’m talking about an open source application, released under the MIT license. In addition, It also requires Java for its correct execution because this is the language where it was developed.

Why Jenkins?

With Jenkins, you can automate your work-flow in large-scale application development with seamless integration.

The concept of Continuous Integration refers to a model in which a source code must be compiled and run from time to time in order to detect bugs and generate reports to improve it.

To put it another way, developers soon upload their source code to the version control repository, it is compiled, executed, and finally tested. Jenkins automates this process and makes it almost routine. However, Jenkins’ power is not limited to this.

Let’s install it on CentOS 7.

0. What you need

The purpose of this tutorial is to install Jenkins on CentOS 7. The process is not complex, but some things are required before starting:

  • It is necessary to execute commands as the root user.
  • The terminal is the most powerful and versatile tool Linux has. Today you will use it quite a lot, so it is recommended that you have some previous knowledge about its use.
  • The team must have CentOS 7 if you use Ubuntu 18.04 this tutorial is not for you. But this one is.

1.- Upgrade the system

I always recommend updating the system, before performing any installation. Because you can get the latest security updates and thus have a more protected and reliable system.

:~$ su -
:~# yum update
1.- Upgrading the system
1.- Upgrading the system

As I said before, doing this gives the system more secure.

2. Install Java

Jenkins requires Java to run properly, so you have to install it to continue the installation.

:~# yum install java-1.8.0-openjdk
2.- Installing Java
2.- Installing Java

Once the installation is complete, check the installed Java version.

:~# java -version
3.- Showing the Java version
3.- Showing the Java version

As you can see in the image, Java has been correctly installed.

3. Add the Jenkins Repository

Jenkins does not come by default in the CentOS 7 repositories. So we have two ways to install it. The first is to download the package in .rpm format and install it. The second is to add the repository and install it using yum. For this tutorial, I will choose the second option.

First, download the repo file.

:~# wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
4.- Adding the Jenkins repository file
4.- Adding the Jenkins repository file

Then, import the GPG key.

:~# rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
5.- Import the GPG key
5.- Import the GPG key

Finally, install Jenkins.

:~# yum install Jenkins
6.- It's time to install Jenkins
6.- It’s time to install Jenkins

At the end of the download, Jenkins will be installed on the computer.

Then, enable Jenkins service to start at the system startup.

:~# systemctl enable jenkins
:~# systemctl start jenkins
7.- Enabling Jenkins service
7.- Enabling Jenkins service

Next, check the Jenkins status.

:~# systemctl status jenkins
8.- Checking the Jenkins service status
8.- Checking the Jenkins service status

As you can see in the image, Jenkins is correctly running.

4. Setting the firewall rules

We know that CentOS 7 takes the security of the system very seriously and that is why the firewall does not allow any connection by default. For Jenkins to work, the firewall must allow connections through port 8080.

:~# firewall-cmd --zone=public --add-port=8080/tcp --permanent
:~# firewall-cmd --zone=public --add-service=http --permanent
:~# firewall-cmd --reload
9.- Settings firewall rules
9.- Settings firewall rules

Now, Jenkins can work well.

5. Access Jenkins web interface

Jenkins has a configuration panel with a web interface. However, before accessing the panel, it is necessary to obtain the administrator password. To do this, run the following:

#grep -A 5  password /var/log/jenkins/jenkins.log
10.- Getting the Jenkins password
10.- Getting the Jenkins password

Now, you can go to the web browser and open http://IP_SERVER:8080 and you will see this screen.

11.- Jenkins main screen
11.- Jenkins main screen

As you can see, you have to enter the password you have previously obtained.

When you set the password, you will be asked if you want to install additional plugins. I will choose to install the suggested plugins.

12.- Jenkins installation
12.- Jenkins installation

The installer will then complete the installation.

13.- Completing the installation
13.- Completing the installation

Next, you will need to enter information about the user to be created. Enter your username, password and email address.

14.- Creating the first admin user
14.- Creating the first admin user

When the installation is complete, you can access the Jenkins main screen.

16.- Jenkins main screen
16.- Jenkins main screen

So, that’s it.

Conclusion

Jenkins allows you to deploy and automate important tasks for application development in an enterprise environment. To install it is not complicated in a CentOS 7 system. However, it requires some previous knowledge of Linux.

Please spread this article through your social networks.

Read More

If You Appreciate What We Do Here On OsRadar, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Telegram
  2. Subscribe to our email updates: Sign Up Now
  3. Become a Supporter - Make a contribution via PayPal

We are thankful for your support.

LEAVE A REPLY

Please enter your comment!
Please enter your name here