Install Jenkins on Ubuntu Server 18.04 and Virtualbox – Step by Step in 20 minutes

Find out more

1Fabio

Install Jenkins on Ubuntu Server 18.04 and Virtualbox – Step by Step in 20 minutes

Jenkins in an open-source continuous integration server. For this tutorial I am assuming that you are already familiar with Virtualbox and it’s already installed on your system, if not you need to install virtual box from here.

Steps to Install Jenkins using Ubunu 18.04 and Virtualbox 6.0

  1. Download the latest version of Ubuntu Server
  2. Create a virtual machine using Virtualbox
  3. Install Ubuntu
  4. Install java 8
  5. Download and install Jenkins

Download Ubuntu Server

Browse to this link and download the latest ubuntu server https://www.ubuntu.com/download

Crate a Virtual Machine

Download and install Virtualbox if not installed already.
Select new to create a new virtual machine, type the name, select the os and follow the instruction on screen.

https://www.virtualbox.org/wiki/Downloads

Install Ubuntu 18.04

Now install the downloaded version of Ubuntu on the Virtual machine that you just created following the instruction on screen.

  1. Create a new machine

VirtualBox menu Create new machine

2. Add a Name to the Machine

Virtual Box Name the Machine

Tip: if you start with the name of the Operative system like Ubuntu the type and version will be populated automatically.

3. Setup the memory you want to give to the machine.

Setup the ram option for the virtual machine

4. Configure the hard disk

 

Remember to attach the .iso file of Ubuntu that you have downloaded in the storage CD section of virtualbox in your virtual machine settings page.

Add the iso file

Install Java 8

https://help.ubuntu.com/community/Java


sudo apt install openjdk-8-jdk

Check the java version installed

java -version

Chose the default java to use (optional)
if you have multiple java versions you can set the one you want to use at boot time

sudo update-alternatives --config java

Install Jenkins

First you need to add the package key to your Ubuntu packaging system, https://jenkins.io/doc/book/installing/#debianubuntu

wget –no-check-certificate ---vvv -O – https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -

Add the package repository to the source list so it gets updated when typing apt-get update and install Jenkins


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

Jenkins is now installing on your ubuntu server.

If it trows an error, you might want to check that the correct java version is installed onto the system.

```
java -version
```

Configure the version using alternative java command
```
sudo update-alternative --config java
```

Select the desided version ( java 8)
```
sudo apt-get update && sudo apt-get upgrade
```

Warning: apt had planned for dpkg t odo more than it reported back (0vs4)
affected packages: jenkins:amd64

Reboot the system

```sudo reboot```

 

Change the port that jenkins listens to 8082 instead of 8080 (Optional )

```
sudo nano /etc/default/jenkins
```

# Replace the line HTTP_PORT=8080 with HTTP_PORT=8082

Start the Jenkins service

```
sudo service jenkins start

“`

You can check the status of the Jenkins service using this systemctl command:

```
systemctl status jenkins

or

service jenkins status
“`

VirtualBox – Setup the nat network port forwarding

You need to setup the nat network of your virtual box to forward request from your virtualbox network v adapter to the actual virtual machine that you created. My network adapter has an ip of 192.168.56.1 this is the default after you install virtualbox.

Configure port forwarding

Visit file>preferences>netwok> settings then click the cog icon and visit port-forward.

Setup the Nat netwok to forward ip 192.168.56.1 port 8082 to 10.0.2.15 8082

the 10.0.2.15 is the ip address of the virtual machine that we just created, double check it’s ip address by logging into the terminal of your ubuntu server and type ifconfig.

Unlock Jenkins

Now you can open the browser of your local host machine and  visit 192.168.56.1:8082. This is how it should look like now.

Unlock jenkins screen

copy the link show, open the jenkins machine and from the terminal
```
sudo su
cat /var/lib/jenkins/secrets/initialAdminPassword
```

f99bbdf443534aa8a70de5bf04606060
copy the password and unlock jenkins.

CONGRATS! JENKINS IS SUCCESSFULLY INSTALLED!!

Setup recomended plugins

On the next screen Jenkins will ask to setup default plugins or choose from a list of plugins. Setup the defaults to start.

Jenkins Default plugins setup

Jenkins User dashboard

After it finishes wait until it loads.

Jenkins Dashboard

To find out how to use Jenkins read the official documentation: https://jenkins.io/doc

Jenkins and PHP:  https://jenkins.io/solutions/php/


The Author

Written by:

I am a senior entrepreneur, full-stack php developer, Laravel, WordPress, Magento experience with knowledge responsive web design, frameworks and SEO techniques. Several years of experience as CAD Designer and website-eCommerce administrator with digital marketing experience. Analytical mindset with problem solving skills. Productive, self motivated and well organised. I’m a bilingual Italian-English with a strong personality, very flexible, and enthusiastic to work in other Cities or Countries. Loving knowledge and new challenges if there is anything that I don’t know how to do, I’m always likely to learn it. I put passion and care in everything I do. I’ve a strong sense of responsibility, ethics and duty. I’m a friendly, enthusiastic open minded person, always happy to work in a team but also capable of working on my own.


Related Posts

GitLab installation Cover

How To Install a GitLab Server in 20 Minutes

Mobile application development with flutter

Build Mobile Apps With Flutter

Multi-language-laravel

Laravel 5.7 Multi-language | Complete guide


Comments

Leave a comment

Your email address will not be published. Required fields are marked *


Need Help?

Just get in touch! I'm always happy to help.


Get professional advice today on a wide range of solutions for your business.

Contact Fabio