Displaying items by tag: jekins

Wednesday, 26 February 2020 17:52

How to: Install jekins on your linux

Guys, Before talking about how to install jenkins on linux, shall we discuss a little bit about actually what is jenkins ? It is a automation tool which has written in java language. It is an open source application. Jenkins helps for automation tasks and mostly used by system administrators, cloud engineers, DevOps engineers and developers.



As an example if we take running Ansible playbooks on the ansible master node itself, we can use jenkins tool for running ansible playbooks. Since jenkins is a web tool, system

administrators/DevOps can easily use it taking the advantage of it’s different types plugins for specific purposes. Jenkins is also very useful for Continuos Integration and Continous delivery

(CI/CD ). Thanks to  jenkins, developers can build and test their software projects by doing the changes continously and can take the project to the production level without any distruption to the

users because of the pre testing stages running in continous delivery.


So we are going to see different ways of how to install jenkins on Linux.


1) Install Jenkins using yum command

commands :
sudo yum update -y
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo yum install jenkins -y
sudo systemctl start jenkins
sudo systemctl enable jenkins
Note : Since Jenkins is a java application, first of all you must have installed java on your centos.



 command – sudo yum install java-1.8.0-openjdk-devel




 We can check if the port for jenkins has opened. Remember that jenkins is using port 8080 as it’s default port. But we can change it if we need. 



To access your Jenkins after the Installation, Open your web browser and got to your centos local ip

with port 8080 ( or localhost:8080 ) or if you are running a virtual machine your public ip with port 8080

could be accessed. I am here using the public ip attached to my virtual machine to get the jenkins web





As shown in the browser you need to access that /var/lib path and get the Initial Admin password.

Then Install suggested plugins and login as admin ( if needed you can create another account ).

here we go, finally we have installed jenkins.





2) Install Jenkins on a tomcat

What is tomcat ? Actually tomcat is a application server from apache foundation which executes java

servlets and renders the webpages which is having java coding. Since Jenkins is a tool build with

java, we are trying to install jenkins on tomcat.


commands :

sudo yum update -y
sudo yum install java-1.8.0-openjdk-devel
cd ~
wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.0.M10/bin/apache-tomcat-9.0.0.M10.tar.gz
tar xzfv apache-tomcat-9.0.0.M10.tar.gz
mkdir Tomcat9
mv apache-tomcat-9.0.0.M10 Tomcat9
cd Tomcat9/bin

Now  we have installed tomcat on one of our directories in home folder and started tomcat server. You

can check of the port 8080 has opened.

sudo netstat -plunt |grep 8080

Now open the browser with your localhost:8080 or if you are running a virtual machine then your vm

local machine ip with port 8080 or your public ip with port 8080.




 Ok, now tomcat is ready to searve for java applications. Let’s get our jenkins into tomcat.

Download the jenkins war file from this link. Jenkins war releases. I use version 2.214 ( latest war file ).

commands :

cd ~/Tomcat9/webapps

wget http://updates.jenkins-ci.org/download/war/2.214/jenkins.war



Now we will get back to the browser.

try now the url as your tomcat url/jenkins, like localhost:8080/jenkins



 See now you are running your jenkins on tomcat. You can check the java process on the server. ps -ef|grep java



 If you want to shutdown or restart the jenkins, you can do it by shutting down the tomcat node. Simply

do as below

cd ~/Tomcat9/bin

./shutdown.sh – this will shutdown the tomcat, so jenkins will also be shutdown

./startup.sh = this will start your tomcat and jenkins will be back online




4) Install Jenkins on a docker container

commands :

First we need to install docker engine in our centos, So follow the below

sudo yum update -y

sudo yum install -y yum-utils device-mapper-persistent-data lvm2 -y

sudo yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo

sudo yum -y install docker-ce

sudo systemctl start docker && sudo systemctl enable docker

now switch to root user – sudo su


To verify docker, use command docker ps and docker version to check the docker version.



 Guys now we have installed docker on our centos. Now we will pull our jenkins image to our centos.






docker images



 Now i am creating a docker container from jenkins image as below



You can see that i have exposed the container to be accesible from the localhost ip from host port

8080. Open the browser and try to access the jenkins container with port 8080.




So guys we discussed how to install jenkins on centos in three different ways. Hope more articles

related to jenkins on future.



Published in GNU/Linux Rules!
Tagged under