Installing Jenkins on Ubuntu:

Jenkins is an open-source automation tool which offers an easy way to set up a continuous integration and continuous delivery (CI/CD) pipeline.

OS: Ubuntu 18.04 Bionic Beaver LTS

CI/CD Tool: Jenkins

Java: OpenJDK8

First Step:

  1. Install Java–> since Jenkins is built on Java application, install Java JDK.

sudo apt update

sudo apt install openjdk-8-jdk

cloud_user@0d52cf7c051c:~$ sudo apt update
[sudo] password for cloud_user:
Hit:1 http://us-west-1.ec2.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://us-west-1.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:3 http://us-west-1.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu bionic-security InRelease
Reading package lists… Done
Building dependency tree
Reading state information… Done
1 package can be upgraded. Run ‘apt list –upgradable’ to see it.
cloud_user@0d52cf7c051c:~$

cloud_user@0d52cf7c051c:~$ sudo apt install openjdk-8-jdk
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
ca-certificates-java fonts-dejavu-extra java-common libatk-wrapper-java libatk-wrapper-java-jni libgif7 libice-dev libpcsclite1 libpthread-stubs0-dev libsm-dev
libx11-dev libx11-doc libxau-dev libxcb1-dev libxdmcp-dev libxt-dev openjdk-8-jdk-headless openjdk-8-jre openjdk-8-jre-headless x11proto-core-dev x11proto-dev
xorg-sgml-doctools xtrans-dev
Suggested packages:
default-jre libice-doc pcscd libsm-doc libxcb-doc libxt-doc openjdk-8-demo openjdk-8-source visualvm icedtea-8-plugin libnss-mdns fonts-ipafont-gothic
fonts-ipafont-mincho fonts-wqy-microhei fonts-wqy-zenhei fonts-indic
The following NEW packages will be installed:
ca-certificates-java fonts-dejavu-extra java-common libatk-wrapper-java libatk-wrapper-java-jni libgif7 libice-dev libpcsclite1 libpthread-stubs0-dev libsm-dev
libx11-dev libx11-doc libxau-dev libxcb1-dev libxdmcp-dev libxt-dev openjdk-8-jdk openjdk-8-jdk-headless openjdk-8-jre openjdk-8-jre-headless x11proto-core-dev
x11proto-dev xorg-sgml-doctools xtrans-dev
0 upgraded, 24 newly installed, 0 to remove and 1 not upgraded.
Need to get 43.9 MB of archives.
After this operation, 170 MB of additional disk space will be used.
Do you want to continue? [Y/n] click Yes

Once Java is installed add repository as a second step

2nd Step: Add the Jenkins repository:

This step is required to trust the package

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

Then add Jenkins repository to the system

sudo sh -c ‘echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list’

3rd Step: Install Jenkins:

Once repository is enabled install Jenkins as mentioned below.

$ Sudo apt update

$ sudo apt install jenkins

cloud_user@0d52cf7c051c:~$ sudo apt update
Hit:1 http://us-west-1.ec2.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://us-west-1.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:3 http://us-west-1.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu bionic-security InRelease
Reading package lists… Done
Building dependency tree
Reading state information… Done

cloud_user@0d52cf7c051c:~$ sudo apt install jenkins
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
daemon
The following NEW packages will be installed:
daemon jenkins
0 upgraded, 2 newly installed, 0 to remove and 1 not upgraded.
Need to get 71.9 MB of archives.
After this operation, 72.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] Click yes

After installing the Jenkins verify Jenkins service status.

systemctl status jenkins

cloud_user@0d52cf7c051c:~$ systemctl status jenkins
● jenkins.service – LSB: Start Jenkins at boot time
Loaded: loaded (/etc/init.d/jenkins; generated)
Active: active (exited) since Sat 2021-12-25 08:28:44 UTC; 1min 1s ago
Docs: man:systemd-sysv-generator(8)
Tasks: 0 (limit: 1114)
CGroup: /system.slice/jenkins.service

Allow port 8080 on Ubunutu inbuilt firewall

cloud_user@0d52cf7c051c:~$ sudo ufw allow 8080
Rules updated
Rules updated (v6)

Now browse server IP as with port 8080 and you will see below page

Get the password from Ubuntu server as mentioned below

cloud_user@0d52cf7c051c:~$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword
41d068c541524bc194d7546e47b28458

Once you get the password in Administrator password window and click continue.

On next wizard you will see whether you want to install suggested plugins or custom plugins. Select suggested plugins and click the button.

It will start installing plugins as mentioned below.

Once plugins are installed, next wizard will ask to provide admin name and its credentials.

Provide all the required details and you are ready to use Jenkins.