How to install Jenkins

Approach 1: Installing Jenkins as a service in Linux machine

For Centos7/Redhat/OracleLinux operating system

Go to Jenkins official download page Jenkins official download page

Click on Linux

Jenkins website Download page

Click on Red Hat / CentOS

jenkins website Download Linux page

jenkins website Download centos page

Prerequisites:
Run the below commands to install Jenkins stable release and Java 11
sudo wget -O /etc/yum.repos.d/jenkins.repo \
    https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
sudo yum upgrade
sudo yum install jenkins java-11-openjdk-devel
sudo systemctl daemon-reload
Start and enable the Jenkins to automatically start after reboot
sudo systemctl start jenkins
sudo systemctl enable jenkins
Check the Jenkins running status
sudo systemctl status jenkins

jenkins running status

For Ubuntu operating system

Go to Jenkins official download page Jenkins official download page

Click on Linux

Jenkins website Download page

Click on Debian/Ubuntu

jenkins website Download Linux page

jenkins website Download centos page

Prerequisites:
Run the below commands to install Java 11
sudo apt update
sudo apt install openjdk-11-jdk
Run the below commands to install Jenkins stable release
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > \
    /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins
Enable the Jenkins to automatically start after reboot
sudo systemctl status jenkins
sudo systemctl enable jenkins
Check the Jenkins running status
sudo systemctl status jenkins

Approach 2: Install Jenkins using docker

If you have followed Approach 1 you can skip Approach 2 and continue with Common steps for configuring Jenkins

Now we will install jenkins as a docker container

Ports
Volumes
Problems:
docker run --name jenkins -d -p 8080:8080 -p 50000:50000 -v jenkins-volume:/var/jenkins_home jenkins/jenkins:lts-jdk11

Common steps for configuring Jenkins

Once Jenkins is installed, by default jenkins starts on port 8080

we can access the jenkins by opening the ip-address:8080 or localhost:8080 (if its insatlled locally) from the browser

jenkins ublock password page

Now get the initialadminpassword from /var/lib/jenkins/secrets/initialAdminPassword file

Change to root user and open the /var/lib/jenkins/secrets/initialAdminPassword file to get the password

jenkins intila admin password

Click on continue

Click on Install suggested plugins

jenkins website Download centos page

This will automatically install the necessary plugins for Jenkins

jenkins website Download centos page

Enter the username, password and click on Save and Continue

jenkins set username password

Click on Save and Finish

jenkins final save and finish

Click on Start using Jenkins

jenkins start using

Jenkins Dashboard

jenkins start using