Are you spending a lot of time deploying code in your infrastructure and with many steps and software? Don’t worry; you are at the right place to learn about the famous open-source tool Jenkins, which helps build and deploy the code with a click of a button and has various other benefits.
In this tutorial, you will learn what is Jenkins and how can you install Jenkins on ubuntu 18.04 and setup step by step. Still Interested?
Table of Content
- What is Jenkins
- Prerequisites
- How to Install Java on ubuntu 18.04 machine
- How to Install Jenkins on Ubuntu 18.04 LTS
- How to setup Jenkins on ubuntu
- Workflow of Jenkins and Code deployment
- Conclusion
What is Jenkins?
Jenkins is an open-source automated CI/CD tool where CI stands for continuous integration and CD stands for Continuous delivery. Jenkins has its own built-in Java servlet container server, which is Jetty. Jenkins can also be run in different servlet containers such as Apache tomcat or glassfish.
- Jenkins can be deployed to the local machine or premises data center, or any cloud.
- Jenkins takes your code, any sort of code such as python, java, or go or JS, etc., and compiles it using different compilers such as MAVEN, one of the most used compilers, and then builds your code in war or Zip format and sometimes as a docker image.
- Jenkins deploys the code when required and integrates easily with various third-party tools.
Related: Python Flask Tutorial: All about Python flask
Prerequisites
- Ubuntu 18.0.4 machine preferably; if you don’t have any machine, you can create an ec2 instance on the AWS account.
- It is recommended to have 4GB of RAM
- At least 5GB of drive space
You may incur a small charge for creating an EC2 instance on Amazon Managed Web Service.
How to Install Java Version 11 on ubuntu 18.04 machine
Before you dive into the installation of Jenkins on your ubuntu machine, you will need Java as a prerequisite, without which Jenkins will not work. So, let’s begin and learn how to Install Java Version 11 on an Ubuntu 18.04 machine using a few basic steps.
- Firstly, install java using the apt install command as shown below.
sudo apt install default-jdk # Here we are installing Java Version: Java SE 11 (LTS)
- Next, verify the java version on your machine.
java -version # To check the Installed Java Version

- Check the location of java by using the which and where command.
which java : # It will locate executable file location which is /usr/bin/java
whereis java # It will give the location of all the files related to Java

The Installation directory of Java is /usr/lib/jvm/java-1.8.0-openjdk-amd64, and this confirms that Java is successfully installed on our ubuntu 18.04 machine. Now, let us install Jenkins.
How to Install Jenkins on Ubuntu 18.04 LTS
Now that you have Java installed on your ubuntu machine. Now, it’s time to install Jenkins, an easier and more straightforward task. Let’s dive in to install Jenkins on Ubuntu 18.04 LTS machine.
- First, update your system packages on the ubuntu machine using the below command.
sudo apt update
- Next, add Jenkins Public key to your system so that this key can trust the jenkins.io site to download the repository or any packages.
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
- Now, add the Jenkins repository to your system and update your system.
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > \
/etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
- Now install the Jenkins package using the apt-get command.
sudo apt-get install jenkins
As of now, Jenkins service should be up and running. To check the status of Jenkins, run the below command as shown.
service jenkins status

How to setup Jenkins on ubuntu
Now that you have installed Jenkins on your ubuntu machine successfully and verified by running the service command. But the installation is just an initial stage; you will need to set the Jenkins to make it work properly. Let’s learn step by step how to set Jenkins instance.
- Open the Jenkins instance on your favorite web browser by going to <Jenkins-installation-server-ip-address>:8080.
- As soon as the URL is opened, it will prompt for the administrator password. The password can be found on /var/lib/Jenkins/secrets/initialAdminPassword directory, as shown below.

- Now obtain the password by going to the Jenkins server and viewing the following content.
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
- After successfully adding the Jenkins admin password, you will be prompted for Plugins installation. We will select the Install Suggested Plugins option as this is the demo.


- Once the plugins are successfully installed, then it will prompt to create a First admin user. Please fill in the required information and keep it safe with you, as you will use this later to log in.

- Now Jenkins URL configuration screen will appear, and you can keep the default URL as it is and click on save and finish.


- Now Jenkins instance is ready for use. Click “Start using Jenkins.” After you click, you will see Jenkins Dashboard, where you create New Jobs by clicking on New Item.

Workflow of Jenkins deployment
This section is an additional section that provides you a basic overview of how a Jenkins deployment happens step by step and what Jenkins can do for you. Let’s get into it.
- Once Jenkins is installed, install plugins as per the requirement, whether terraform, bitbucket, python, blue-ocean, etc.
- Jenkins is configured so that it can fetch the code from any of the repositories such as GIT, bitbucket, SVN, or TFS.
- Once you define the code repository, Jenkins pulls the code, compiles it using plugins if required, and later builds it. You can include a few test cases along with a build to test some functionalities of code.
- Later you deploy the code on required environments such as AWS, GCP, Windows machines, Linux machines, etc.

Conclusion
In this tutorial, you learned what Jenkins is, how to install Java on the ubuntu 18.04 machine, how to Install Jenkins on Ubuntu 18.04 LTS, and how to set up Jenkins on ubuntu and setup.
Jenkins is a handy tool for CI and CD purposes and is most widely used, which helps manage your organization’s deployments.
Now that you have Jenkins installed and set up, which application are you planning to deploy?
Pingback: The Ultimate Guide : Getting Started with Jenkins Pipeline