Install Jenkins on Ubuntu

Ankita LunawatAnkita Lunawat
2 min read

Update the System

Update the package index on your Ubuntu system.

sudo apt update

Install Java

Jenkins requires Java to run. Install OpenJDK using the following command:

sudo apt install openjdk-11-jdk -y

You can verify the Java installation by checking the version.

java -version

Add Jenkins Repository

To install the latest stable Jenkins, you need to add the Jenkins repository to your system. Import the GPG key first.

curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee \
  /usr/share/keyrings/jenkins-keyring.asc > /dev/null

Then add the Jenkins repository to your system:

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

Install Jenkins

Update your system again after adding the repository.

sudo apt update

Install Jenkins now

sudo apt install jenkins -y

Start and Enable Jenkins

Once installed, start the Jenkins service.

sudo systemctl start jenkins

Enable the Jenkins service to start automatically on system boot.

sudo systemctl enable jenkins

Adjust Firewall

If you are using a firewall, open port 8080 (the default Jenkins port) so Jenkins can be accessed.

sudo ufw allow 8080
sudo ufw reload

Access Jenkins

Jenkins runs on port 8080 by default. You can access it by visiting the following URL in your web browser.

http://your_server_ip_or_domain:8080

Unlock Jenkins

  1. When you first access Jenkins, you will be prompted to unlock it.

  2. To get the initial admin password and run.

     sudo cat /var/lib/jenkins/secrets/initialAdminPassword
    
  3. Copy the password and paste it into the Jenkins interface.

Install Suggested Plugins and Create Admin User

  1. Jenkins will prompt you to install suggested plugins. Click on Install suggested plugins.

  2. Once the installation completes, create an admin user.

That's it! Jenkins is now installed and running on your Ubuntu system.

0
Subscribe to my newsletter

Read articles from Ankita Lunawat directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ankita Lunawat
Ankita Lunawat

Hi there! I'm a passionate AWS DevOps Engineer with 2+ years of experience in building and managing scalable, reliable, and secure cloud infrastructure. I'm excited to share my knowledge and insights through this blog. Here, you'll find articles on: AWS Services: Deep dives into core AWS services like EC2, S3, Lambda, and more. DevOps Practices: Best practices for CI/CD, infrastructure as code, and automation. Security: Tips and tricks for securing your AWS environments. Serverless Computing: Building and deploying serverless applications. Troubleshooting: Common issues and solutions in AWS. I'm always eager to learn and grow, and I hope this blog can be a valuable resource for fellow DevOps enthusiasts. Feel free to connect with me on [LinkedIn/Twitter] or leave a comment below!