How to Install Jenkins on Ubuntu?
Updated: Apr 10
Jenkins is an open-source automation server that helps to automate various tasks like building, testing, and deploying software. If you're working with AWS, you can install Jenkins on an EC2 instance and automate your build and deployment processes. This blog post will walk you through installing Jenkins on an EC2 instance.
Before we begin, you'll need the following:
An AWS account
An EC2 instance running a Linux operating system (Ubuntu 22.04) with the security group well configured
An SSH client to connect to the EC2 instance
Step 1: Install Java
When you install Jenkins on an Ubuntu instance, it downloads the Jenkins WAR (Web Application Archive) file containing the Jenkins application and its dependencies. To run the Jenkins application, you need to have a Java Runtime Environment (JRE) or a Java Development Kit (JDK) installed on your machine.
sudo apt update sudo apt install openjdk-11-jre java -version
Step 2: Add the Jenkins Repository Key
The second step is to add the Jenkins repository key to your system. This key is used to verify the packages you download from the Jenkins repository. Run the following command to add the key:
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
Step 3: Add the Jenkins Repository
After adding the repository key, you must add the Jenkins repository to your system. This command line uses the new repository signing keys for the Linux installation packages (> Jenkins 2.387.2) - More info here and here.
Run the following command to add the repository:
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
Step 4: Update the Package Lists
Next, update the package lists to ensure that your system has the latest information about available packages. Run the following command:
sudo apt-get update
Step 5: Install Jenkins
Once you have added the repository and updated the package lists, you can install Jenkins using the following command:
sudo apt-get install jenkins -y
This command will download and install Jenkins, along with any necessary dependencies.
Step 6: Start the Jenkins Service
After installing Jenkins, you can start the Jenkins service using the following command:
sudo systemctl start jenkins
Step 7: Access the Jenkins Web Interface
Once the Jenkins service runs, you can access the Jenkins web interface by navigating to http://your-ip-instance:8080 in your web browser. You can follow the prompts from there to set up your Jenkins installation.
Step 8: The first Connection
When first accessing http://your-ip-instance:8080, Jenkins will ask for a password that is located at /var/lib/jenkins/secrets/initialAdminPassword. Here is how to access it:
sudo chmod 755 /var/lib/jenkins/secrets sudo nano /var/lib/jenkins/secrets/initialAdminPassword
This blog post showed you how to install Jenkins on an EC2 instance. With Jenkins installed, you can automate your build and deployment processes and save time and effort. We hope this tutorial was helpful, and if you have any questions or feedback, please let us know in the comments.