How to Install Jenkins on Ubuntu

Are you looking to streamline your software development process and embrace the power of continuous integration and delivery? Look no further than Jenkins, the open-source automation server that has taken the DevOps world by storm. In this comprehensive guide, we’ll walk you through the process of installing Jenkins on Ubuntu, empowering you to build, test, and deploy your applications with ease.

Whether you’re a seasoned Linux administrator, a curious developer, or a tech enthusiast eager to explore the world of automation, this guide is tailored to meet your needs. We’ll break down the installation process into simple, easy-to-follow steps, ensuring that you can get Jenkins up and running on your Ubuntu system in no time. So, let’s dive in and embark on this exciting journey together!

Prerequisites for Installing Jenkins on Ubuntu

Before we begin the installation process, it’s essential to ensure that your Ubuntu system meets the necessary prerequisites. First and foremost, you’ll need a running instance of Ubuntu. Whether you’re using Ubuntu on a physical machine, a virtual machine, or a cloud-based server, make sure you have access to the command line interface.

Next, verify that you have sufficient system resources to run Jenkins effectively. While the exact requirements may vary depending on your specific use case, it’s recommended to have at least 1 GB of RAM and a dual-core processor. Keep in mind that these are minimum requirements, and for optimal performance, you may want to allocate more resources based on the size and complexity of your projects.

Installing Java Development Kit (JDK)

Installing Java Development Kit (JDK)

Jenkins is built on the Java platform, which means you’ll need to have the Java Development Kit (JDK) installed on your Ubuntu system. The JDK provides the necessary tools and libraries to run Java applications, including Jenkins.

To install the JDK, open a terminal window and run the following command:

sudo apt install openjdk-11-jdk

This command will download and install the OpenJDK 11, which is a widely used and supported version of the Java Development Kit. Once the installation is complete, you can verify the Java version by running:

java -version

If the installation was successful, you should see the Java version information displayed in the terminal.

Adding the Jenkins Repository

To ensure that you have access to the latest stable version of Jenkins, it’s recommended to add the official Jenkins repository to your Ubuntu system. This will allow you to easily install and update Jenkins using the package manager.

First, add the repository key to your system by running the following command:

wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -

Next, add the Jenkins repository to your system’s sources list:

sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

With the repository added, update the package list to include the newly added Jenkins repository:

sudo apt update

Installing Jenkins

Installing Jenkins

Now that you have the JDK installed and the Jenkins repository added, you’re ready to install Jenkins itself. The installation process is straightforward and can be done using the package manager.

To install Jenkins, run the following command:

sudo apt install jenkins

The package manager will handle the installation process, downloading and configuring the necessary files and dependencies. Once the installation is complete, Jenkins will be installed on your Ubuntu system.

Starting and Enabling Jenkins

After the installation, you need to start the Jenkins service and enable it to run automatically at system startup. This ensures that Jenkins is always available and ready to handle your continuous integration and delivery tasks.

To start the Jenkins service, use the following command:

sudo systemctl start jenkins

To enable Jenkins to start automatically at system boot, run:

sudo systemctl enable jenkins

You can verify the status of the Jenkins service by running:

sudo systemctl status jenkins

If the service is running correctly, you should see output indicating that Jenkins is active and running.

Configuring Firewall Rules

By default, Jenkins runs on port 8080. To access the Jenkins web interface from a remote machine, you need to ensure that the firewall rules allow traffic on this port.

If you have the UFW (Uncomplicated Firewall) enabled on your Ubuntu system, you can allow traffic on port 8080 by running:

sudo ufw allow 8080

If you’re using a different firewall or have specific security requirements, adjust the firewall rules accordingly to permit access to the Jenkins port.

Accessing the Jenkins Web Interface

Accessing the Jenkins Web Interface

With Jenkins installed and the firewall configured, you’re ready to access the Jenkins web interface. Open a web browser and navigate to:

http://your_server_ip:8080

Replace your_server_ip with the IP address or hostname of your Ubuntu server.

On the first access, you’ll be prompted to unlock Jenkins by providing an initial admin password. To retrieve the password, run the following command in the terminal:

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

Copy the password and paste it into the Jenkins web interface to unlock Jenkins.

Completing the Jenkins Setup

After unlocking Jenkins, you’ll be guided through the initial setup process. You can choose to install the recommended plugins, which provide a set of commonly used functionalities, or select specific plugins based on your requirements.

Once the plugin installation is complete, you’ll be prompted to create an admin user account. Provide a username, password, and other required details to set up the admin account.

Finally, you’ll be asked to confirm the Jenkins URL. By default, it will be the same URL you used to access the Jenkins web interface. Confirm the URL or make any necessary changes.

Conclusion

Congratulations! You have successfully installed Jenkins on your Ubuntu system. With Jenkins up and running, you’re ready to start automating your software development processes, from building and testing to deployment and delivery.

Remember, this guide provided a basic installation of Jenkins. As you dive deeper into the world of continuous integration and delivery, you may want to explore additional configurations, plugins, and integrations to tailor Jenkins to your specific needs.

The power of Jenkins lies in its flexibility and extensibility. As you become more familiar with the tool, don’t hesitate to experiment, customize, and optimize your Jenkins setup to streamline your development workflow and boost productivity.

Marshall Anthony is a professional Linux DevOps writer with a passion for technology and innovation. With over 8 years of experience in the industry, he has become a go-to expert for anyone looking to learn more about Linux.

Related Posts