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
- Download the latest version of Ubuntu Server
- Create a virtual machine using Virtualbox
- Install Ubuntu
- Install java 8
- 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.
Install Ubuntu 18.04
Now install the downloaded version of Ubuntu on the Virtual machine that you just created following the instruction on screen.
- Create a new machine
2. Add a Name to 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.
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.
Install Java 8
sudo apt install openjdk-8-jdk
Check the java version installed
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
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.
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
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
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.
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.
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.
copy the link show, open the jenkins machine and from the terminal
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 User dashboard
After it finishes wait until it loads.
To find out how to use Jenkins read the official documentation: https://jenkins.io/doc
Jenkins and PHP: https://jenkins.io/solutions/php/
Learn more about Jenkins, Join the free tail to get the Complete Jenkins 2 course for free:Free Trail:
Jenkins 2 course: https://pluralsight.pxf.io/q306y