How to Install Jenkins on Ubuntu Amazon EC2 Instance – For Beginners

Jenkins is a widely used open-source automation tool for continuous integration and continuous delivery [CI/CD]. It helps in automating the building, testing, and deployment of applications. In this tutorial, we will go through the steps of installing Jenkins on Ubuntu.

Before we begin, ensure that you have the following requirements:

  • An Ubuntu machine with a minimum of 2GB of RAM and a 2GHz CPU.

Now, let’s dive into the installation steps.

Step 1: Install Java

Jenkins is a Java-based application, so you need to have Java installed on your Ubuntu machine. You can install either the JRE [Java Runtime Environment] or the JDK [Java Development Kit] based on your requirements.

To install the JRE, run the following command in your terminal:

sudo apt install default-jre

To install the JDK, run the following command in your terminal:

sudo apt install default-jdk

After the installation is complete, you can verify that Java is installed by running the following command:

java –version

This command will display the version of Java installed on your machine.

Step 2: Add the Jenkins Repository

To install Jenkins on Ubuntu, you need to add the Jenkins repository to the apt package manager. You can do this by running the following command in your terminal.

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

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

This command adds the Jenkins repository to your system.

Step 3: Update Your System

Next, you need to update your system by running the following command.

sudo apt-get update

This command updates the package list on your system.

Step 4: Install Jenkins

To install Jenkins on your Ubuntu machine, run the following command.

sudo apt-get install Jenkins

This command installs the latest stable version of Jenkins on your machine.

Step 5: Start Jenkins

Once Jenkins is installed, you can start the Jenkins service using the following command.

sudo systemctl start jenkins

This command starts the Jenkins service.

Step 6: Enable Jenkins

After starting Jenkins, you need to enable it to start automatically when the system boots up. You can do this using the following command.

sudo systemctl enable Jenkins

This command enables Jenkins to start automatically on system boot.

Step 7: Opening port 8080 in the firewall

This command used in Linux and Unix-based systems to open port 8080 in the firewall using the ufw [Uncomplicated Firewall] utility.

sudo ufw allow 8080

By running the command “sudo ufw allow 8080,” you are enabling incoming traffic on port 8080 by adding a new rule to the firewall configuration. This allows traffic to pass through the specified port.

Alternatively, you could also add port 8080 to the security group settings to allow access.

Step 8: Verify Jenkins Installation

Open your web browser and go to http://your_server_ip_or_domain:8080. to check that Jenkins is installed and working. You should be able to access the Jenkins login page.

You need to give the administrative password, as shown in the above image. The password can be found by executing the following command.

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

Copy the password and click “Continue“.

Step 9: Install Plugins

After that, you will be requested to set up plugins, as seen below. Choose the “Install Suggested Plugins” option. This will install all of the plugins needed to build your projects. The plugins will take a few minutes to install.

Step 10: Create a user and set a password

After installing the plugins, you need to create a user with a password.

After you click “Save and continue,” you will be directed to the Jenkins Dashboard. Log in with the username and password you have given.

Step 11: Jenkins Dashboard

After completing the installation and setup steps, you will be able to access the Jenkins dashboard.

You can quickly install Jenkins on your Ubuntu system and start using it for automation purposes with the help of this tutorial.

Thank you for taking the time to read this article. We would appreciate it if you could leave a comment if you found it helpful. Please follow us to stay up to date on the latest DevOps and cloud-related tutorials.

Leave a Reply

Your email address will not be published. Required fields are marked *