Aim

In this post we will be installing Jenkins on Ubuntu 18.04

Prerequisite

  • Java 8 or Java 11 must be installed on your machine

Step 1 : Add the Key

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

Step 2 : Update the sources list and apt repository

  • Open the sources file
 sudo vim /etc/apt/sources.list
  • Add the following entry to the sources.list file
deb https://pkg.jenkins.io/debian-stable binary/

Add the stable binary to sources list

sudo apt-get update

Step 3 : Install Jenkins

sudo apt-get install jenkins

Check Jenkins status

systemctl status jenkins
  • You will get the below output
selftuts@node1:~$ systemctl status jenkins
jenkins.service - LSB: Start Jenkins at boot time
   Loaded: loaded (/etc/init.d/jenkins; generated)
   Active: active (exited) since Wed 2020-08-05 15:50:12 UTC; 9min ago
     Docs: man:systemd-sysv-generator(8)
    Tasks: 0 (limit: 3500)
   CGroup: /system.slice/jenkins.service

Aug 05 15:50:04 node1.cluster.local systemd[1]: Starting LSB: Start Jenkins at boot time...
Aug 05 15:50:04 node1.cluster.local jenkins[9538]: Correct java version found
Aug 05 15:50:04 node1.cluster.local jenkins[9538]:  * Starting Jenkins Automation Server jenkins
Aug 05 15:50:11 node1.cluster.local su[9587]: Successful su for jenkins by root
Aug 05 15:50:11 node1.cluster.local su[9587]: + ??? root:jenkins
Aug 05 15:50:11 node1.cluster.local su[9587]: pam_unix(su:session): session opened for user jenkins by (uid=0)
Aug 05 15:50:11 node1.cluster.local su[9587]: pam_unix(su:session): session closed for user jenkins
Aug 05 15:50:12 node1.cluster.local jenkins[9538]:    ...done.
Aug 05 15:50:12 node1.cluster.local systemd[1]: Started LSB: Start Jenkins at boot time.
  • Note the Active: active (exited) since Wed 2020-08-05 15:50:12 UTC; 9min ago which says it is active

Stop Jenkins

systemctl stop jenkins
  • Again check the status
systemctl status jenkins
  • You will get below output
selftuts@node1:~$ systemctl status jenkins
‚óŹ jenkins.service - LSB: Start Jenkins at boot time
   Loaded: loaded (/etc/init.d/jenkins; generated)
   Active: inactive (dead) since Wed 2020-08-05 16:02:53 UTC; 40s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 9783 ExecStop=/etc/init.d/jenkins stop (code=exited, status=0/SUCCESS)

Aug 05 15:50:11 node1.cluster.local su[9587]: + ??? root:jenkins
Aug 05 15:50:11 node1.cluster.local su[9587]: pam_unix(su:session): session opened for user jenkins by (uid=0)
Aug 05 15:50:11 node1.cluster.local su[9587]: pam_unix(su:session): session closed for user jenkins
Aug 05 15:50:12 node1.cluster.local jenkins[9538]:    ...done.
Aug 05 15:50:12 node1.cluster.local systemd[1]: Started LSB: Start Jenkins at boot time.
Aug 05 16:02:52 node1.cluster.local systemd[1]: Stopping LSB: Start Jenkins at boot time...
Aug 05 16:02:52 node1.cluster.local jenkins[9783]: Correct java version found
Aug 05 16:02:52 node1.cluster.local jenkins[9783]:  * Stopping Jenkins Automation Server jenkins
Aug 05 16:02:53 node1.cluster.local jenkins[9783]:    ...done.
Aug 05 16:02:53 node1.cluster.local systemd[1]: Stopped LSB: Start Jenkins at boot time.
  • Note the Active: inactive (dead) since Wed 2020-08-05 16:02:53 UTC; 40s ago which that it is inactive

Start Jenkins

systemctl start jenkins
  • You can then check the status and it will be showing active status

Where all Jenkins data is stored

  • Jenkins stores all the data inside below path
cd /var/lib/jenkins/

Accessing Jenkins

  • By default Jenkins start at port 8080
  • You can open the you browser and access http://:8080
  • This will open the below page

Jenkins installation page

Get Administrator Password

  • The previous step will open a page in your browser
  • It will give you the path where admin password is stored
  • Generally it will be /var/lib/jenkins/secrets/initialAdminPassword
  • view the file at this path and find the admin password. Once you get the password then use that in your browser page
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
  • You will then get the getting started page

Jenkins installation page

  • Click on the install suggested plugins and then the wizard will automatically download all the necessary plugin
  • Once the suggested plugin is installed then you will get a page to create user

Jenkins create user page

  • You can create a new user or click on Skip and continue as admin

  • Then you will get a page for instance configuration. Just click on Save and Finish

  • You will then land to the Jenkins dashboard

Jenkins dashboard

Happy Coding

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x