How to Install & Configure Jenkins on Ubuntu / Debian (16.04LTS,18.04LTS)

Introduction:

Jenkins is an open source automation server which provides hundreds of plugin to perform continues integration and continues delivery for building and deploying projects.

Continuous integration (CI) is a DevOps practice in which team members regularly commit their code changes to the version control repository, after which automated builds and tests are run. Continuous delivery (CD) is a series of practices where code changes are automatically built, tested and deployed to production.

If you are a software developer, Then surely Jenkins suites for you and automate your CI/CD build tasks easily.

Jenkins can automate continuous integration and continuous delivery (CI/CD) for any project. Support for hundreds of plugins in the update center. Which provides infinite possibilities for what Jenkins can do. Jenkins can configure into distributed system that distribute work across multiple node/machines.

Features:

CICD - Continues Integration and Continues Delivery

Plugins - Hundreds of Plugin Support

Extensible - Extended possibilities using its Plugins

Distributed - Distribute work across multiple machines and projects

Prerequisites:

Hardware - RAM > 1GB | HDD > 50GB+ Software - JAVA (JRE 8 | JDK 11)

Following JDK/JRE Versions support for current Jenkins versions

OpenJDK JDK / JRE 8 - 64 bits OpenJDK JDK / JRE 11 - 64 bits

NOTE: Always check JAVA version requirement before proceed the Jenkins installation.

REF: https://www.jenkins.io/doc/administration/requirements/java/

STEP 01: Install Oracel/Open JDK 11

Now, I’m going to install OpenJDK 11 on my system.

Install OpenJDK
sudo apt update

sudo apt-get install openjdk-11-jdk -y

OR

REF: https://www.oracle.com/java/technologies/javase-jdk11-downloads.html

sudo dpkg -i jdk-11.0.7_linux-x64_bin.deb
Set Default JDK Version
sudo update-alternatives --config java

java -version

STEP 02: Install Jenkins Using Debian Repository

Import trusted PGP Key for Jenkins
sudo wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
Add Jenkins Repository
sudo 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'
Install Jenkins
sudo apt-get update

sudo apt-get install jenkins

Jenkins service will automatically start after the installation process is complete. You can verify it by printing the service status

sudo systemctl status jenkins

If it isn’t enabled/started automatically.

sudo systemctl enable jenkins

sudo systemctl start jenkins

STEP 03: Configure Firewall

Allow port 8080 through the Ubuntu firewall

sudo ufw allow 8080/tcp

STEP 04: Initial Setup For Jenkins

Once above configuration completed, Open-up your web browser and access through the IP:PORT.

http://your_ip_or_domain:8080

Now, Head-over to terminal again, and find out the Administrator password using this command

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Copy the password from terminal and paste it in the required field

On the next screen at the initial setup wizard will ask for install suggested plugins or you want to select specific plugins. Click on the Install suggested plugins box, and the installation process will start immediately.

Once the plugins are installed, you will be prompted to set up the first admin user. Fill out all required information and click Save and Continue.

Click on the Start using Jenkins button and you will be redirected to the Jenkins dashboard logged in as the admin user you have created in one of the previous steps.

Now you’ve successfully installed Jenkins on your Ubuntu system.

Bottom Line
I hope you learned how to install Jenkins on Ubuntu. And In the next tutorial, I’ll show you how to integrate GitLab with your newly built Jenkins server.
If you have any questions, Please leave a comment on the YouTube comment section.