How to install Jenkins on the Ubuntu server?

From PheonixSolutions
Jump to navigation Jump to search

Introduction

[edit]

Jenkins is a widely used open-source automation server that facilitates continuous integration and continuous delivery (CI/CD) pipelines. Installing Jenkins on an Ubuntu server allows you to automate various tasks related to software development, testing, and deployment. This guide provides step-by-step instructions to install Jenkins on Ubuntu, ensuring seamless setup and configuration.

Prerequisites for Jenkins Installation

[edit]

1. Ubuntu server with version 18.04, 20.04, or 22.04 and SSH access.

2. A non-root sudo user account for performing administrative tasks.

3. A web server such as Apache or Nginx installed and running on the system.

Steps to Install Jenkins on Ubuntu

[edit]

Step 1: Installing Java Development Kit:

Ensure your system's package lists are up-to-date and then install JDK 11, which is a prerequisite for Jenkins.

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

Verify the successful installation of Java by running:

  java --version

Step 2: Installing Jenkins:

Initiate the installation of Jenkins from the Jenkins repository by executing the following commands:

  curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo tee \ /usr/share/keyrings/jenkins-keyring.asc > /dev/null echo deb [signed- 
  by=/usr/share/keyrings/jenkins-keyring.asc] \ https://pkg.jenkins.io/debian-stable binary/ | sudo tee \ /etc/apt/sources.list.d/jenkins.list > /dev/null sudo apt-get update 
  sudo apt-get install jenkins

Start the Jenkins service:

  sudo systemctl start jenkins.service

Verify the status of Jenkins to ensure it's running:

  sudo systemctl status jenkins

Step 3: Adjusting Firewall and Configuring Jenkins:

Configure the firewall to allow access to Jenkins on port 8080:

  sudo ufw allow 8080 
  sudo ufw enable

Check the status of the firewall:

  sudo ufw status

An administrator password will be needed to proceed with the configuration. It can be easily found inside the /var/lib/jenkins/secrets/initialAdminPassword file. To check the initial password, use the cat command as indicated below:

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

Use the obtained password to proceed with the Jenkins setup wizard through the web interface.

Next, the Customize Jenkins window will appear. We recommend simply selecting the Install suggested plugins option for this step.

Give it a couple of minutes for the installation process to complete. Once it’s done, specify your username, password, full name, and email address, and click on Save and Continue to create an admin user.

Then specify the preferred Jenkins URL and finish the configuration process.

After configuration, the Jenkins dashboard will appear, meaning the Jenkins server installation and initial setup were successful.

Conclusion

[edit]

By following these steps, you can successfully install Jenkins on your Ubuntu server, enabling you to automate various tasks in your software development workflow. Jenkins provides a powerful platform for implementing CI/CD pipelines, automating build, test, and deployment processes, thereby improving efficiency and productivity in software development projects. After completing the installation and configuration, you'll have access to the Jenkins dashboard, ready to create and manage your automation jobs.