How to Install & Configure Jenkins 2.0 on Ubuntu Bionic Beaver 18.04




Jenkins is an Open Source continuous integration (CI) and continuous delivery (CD) tool built in java. Jenkins basically build, test and deploy software projects. It is the most useful development tool one can master. So here we have brought you and in depth installation and configuration guide for Jenkins 2.0 on a Linux Ubuntu Machine.

Why Use Jenkins?

In order to understand why we should use Jenkins we should have a better understanding of continuous integration (CI) and continuous delivery (CD) : Continuous Integration - the practice of constantly merging development work with the main branch. Continuous Delivery - is continual delivery of code to an environment once the code is ready to ship. This could be to staging or production. The product is delivered to a user base, which can be QAs or customers for review and inspection. Developers regularly update their code in the shared repositories such as Github. The changes are made to the source code throughout the day and are built together at the end of the day making it difficult to find out the errors. That's where Jenkins come into the picture. As soon as a developer commits any change to the shared repository, Jenkins will immediately trigger a build, and in case of an error, immediately notify (Continuous Integration CI). With Jenkins, we can also set post-build tests (unit test, performance test, acceptance test) in an automated manner. Whenever there is a successful build, Jenkins will perform these tests and generate a report (Continuous Delivery CD).

So Let Us Now Install Jenkins on our Linux Machine.

Step 1 : Install JDK

The first Jenkins prerequisite is JDK. The following command will install JDK and JRE:
sudo apt-get install openjdk-8-jdk

Step 2 : Install a Web Server

The next thing you need is a Web server like Apache or Nginx. You can install any Web server of your choice. For this tutorial we’ll use Nginx. To install Nginx on your VPS, execute the following command in the command line:
sudo apt-get install nginx
Make sure Nginx is up and running on your Ubuntu based machine by typing in your server’s IP in your web browser and hitting enter. You should be greeted by the Nginx welcome screen.

Step 3 : Install Jenkins

Next we will install Jenkins. Issue the following four commands in sequence to install Jenkins on Ubuntu:
wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins

Step 4 : Type in Administrator Password

By default Jenkins will run on port 8080. To start Jenkins type in the IP of your VPS and the port number 8080. It would look something like this in your browser 192.168.0.1:8080 .You will be asked to enter the administrator password. You can find the password in the /var/lib/jenkins/secrets/initialAdminPassword file. You can use the cat command to display the password:
cat /var/lib/jenkins/secrets/initialAdminPassword

Step 5 : Customize Jenkins

Next, you will see following screen, where we recommend you install the suggested plugins.

Step 6 : Set Admin Login Details for Jenkins

Next, you can set username and password on following screen. After that you will be taken to the Jenkins dashboard, where you can begin working!

Conclusion

It’s really that simple to install Jenkins on Ubuntu. Jenkins as a whole has a low learning curve and, meaning you can start working with it as soon as possible. We hope this tutorial helps improve the development of your project! Good luck!


Channels :