How to install Jenkins in CentOS 7 and Ubuntu?

Last modified: July 30, 2020
You are here:
Estimated reading time: 1 min

How to install Jenkins in Centos 7 and Ubuntu?

Jenkins is an open source Integration tool which is written in Java. It is used for automating the non-human part of whole software development process. It is a server based system running in apache tomcat. It is free in cost.

 

1) Before installation you can update the system using the commands below.

In CentOS

# sudo yum install epel-release

# sudo yum update

# sudo reboot

In Ubuntu

# sudo apt-get update

 

2) Before installing Jenkins you need to setup a JVM on your server.

# sudo yum install java-1.8.0-openjdk.x86_64

 

3) After installing Java you need to set two environment variables:

sudo cp /etc/profile /etc/profile_backup

# echo ‘export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk’ | sudo tee -a /etc/profile

# echo ‘export JRE_HOME=/usr/lib/jvm/jre’ | sudo tee -a /etc/profile

# source /etc/profile

 

4) Add Jenkins repositories using the following command.

In CentOS

#  wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat-stable/jenkins.repo

# rpm –import http://pkg.jenkins.io/redhat-stable/jenkins.io.key

In Ubuntu

# wget -q -O – https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add –

# echo deb http://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list

 

5) Install Jenkins on your server.

In CentOS

# yum install jenkins

In Ubuntu

# apt-get install jenkins

 

6) Start and enable jenkin service

In CentOS
# systemctl start jenkins

# systemctl enable jenkins

In Ubuntu

 

7) Open ports 80 and 8080 on server firewall using the below command.

In CentOS

# firewall-cmd –zone=public –add-port=8080/tcp –permanent

# firewall-cmd –zone=public –add-service=http –permanent

# firewall-cmd –reload

In Ubuntu

# ufw allow 8080

# ufw status

 

8) Now Jenkins has been successfully installed and you can access the service from your portal by using the URL http://yourip:8080

 

9) Run the below command to obtain the admin password.

In CentOS

# grep -A 5 password /var/log/jenkins/jenkins.log

In Ubuntu

cat /var/lib/jenkins/secrets/initialAdminPassword

 

This will conclude the installation of Jenkins! Feel free to contact our support team at [email protected] if you have any additional questions or concerns.

 

Was this article helpful?
Dislike 0
Views: 25