How To Install Jenkins on Ubuntu 18.04

1. Add Repository key to the system

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

2. Add Debian package into sources.list

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

3. Update with a new list

=> sudo apt-get update

4. Install Jenkins

=> sudo apt-get install Jenkins

5. Start Jenkins

=> sudo systemctl start jenkins

=> sudo systemctl status jenkins

● jenkins.service – LSB: Start Jenkins at boot time
Loaded: loaded (/etc/init.d/jenkins; generated)
Active: active (exited) since Wed 2018-05-16 20:56:34 IST; 29s ago
Docs: man:systemd-sysv-generator(8)
Tasks: 0 (limit: 4915)
CGroup: /system.slice/jenkins.service

May 16 20:56:32  systemd[1]: Starting LSB: Start Jenkins at boot time…
May 16 20:56:33 jenkins[5853]: Correct java version found
May 16 20:56:33 jenkins[5853]: * Starting Jenkins Automation Server jenkins
May 16 20:56:33 su[5889]: Successful su for jenkins by root
May 16 20:56:33 su[5889]: + ??? root:jenkins
May 16 20:56:33 su[5889]: pam_unix(su:session): session opened for user jenkins by (uid=0)
May 16 20:56:33 su[5889]: pam_unix(su:session): session closed for user jenkins
May 16 20:56:34 jenkins[5853]: …done.
May 16 20:56:34 systemd[1]: Started LSB: Start Jenkins at boot time.

=> sudo ufw allow 8080

Rules updated
Rules updated (v6)

=> sudo ufw status

Status: inactive

==> sudo ufw allow OpenSSH

ERROR: Could not find a profile matching ‘OpenSSH’

===> sudo apt-get install ssh

===> sudo ufw allow OpenSSH

Skipping adding an existing rule
Skipping adding existing rule (v6)

===> sudo ufw enable

A firewall is active and enabled on system startup

=> sudo ufw status

Status: active

To Action From
— —— —-
8080 ALLOW Anywhere
OpenSSH ALLOW Anywhere
8080 (v6) ALLOW Anywhere (v6)
OpenSSH (v6) ALLOW Anywhere (v6)

6. Setting Jenkins

Unlock Jenkins

>> Use below command

=> sudo cat /var/lib/jenkins/secrets/initialAdminPassword

d10b7834824hsdjfn9ur90206b0sdyfbhs

=> Select Customize Jenkines

Customize Jenkins

=> Getting Started

Getting Started

=> Create Account

Create First Admin User

=> Jenkins is Ready

Jenkins is Ready

=> Start using Jenkins

Start Using Jenkins