Installing and Configuring Jenkins on Ubuntu 24.04

In the fast-paced world of software development, automation reigns supreme. Jenkins, an open-source automation server, emerges as a powerful tool for streamlining your development workflow. This guide delves into the installation and configuration of Jenkins on Ubuntu 24.04, empowering you to orchestrate your builds, tests, and deployments with efficiency.

Prerequisites:

Before embarking on your Jenkins installation journey, ensure your Ubuntu 24.04 system meets these requirements:

  • A non-root user with sudo privileges
  • An active internet connection

Step 1: Install Java

Jenkins is a Java-based application. Here’s how to install the OpenJDK package:

  1. Update Package Lists:

Bash

sudo apt update

  1. Install OpenJDK:

Bash

sudo apt install openjdk-17-jre-headless

This command installs the Java Runtime Environment (JRE) required by Jenkins. Verify the installation by running:

Bash

java -version

A successful installation will display the Java version information.

Step 2: Add the Jenkins Repository

The official Jenkins repository provides the most up-to-date packages. Here’s how to add it to your system:

Bash

wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo gpg --dearmor -o /usr/share/keyrings/jenkins.gpg

This command downloads the Jenkins GPG key and adds it to your system’s keyring. Next, add the repository details to your system’s sources list:

Bash

sudo echo "deb [arch=amd64] https://pkg.jenkins.io/debian-stable binary/" | sudo tee /etc/apt/sources.list.d/jenkins.list

This command creates a new file (jenkins.list) within the /etc/apt/sources.list.d directory, specifying the Jenkins repository location. Finally, update your package lists again:

Bash

sudo apt update

Step 3: Install Jenkins

With the repository added, you can now install Jenkins:

Bash

sudo apt install jenkins

This command retrieves and installs the latest Jenkins package from the official repository. During installation, you might be prompted to choose an initial setup option. Select “Install without authentication” for a basic setup.

Affordable VPS Hosting With Dracula Servers

Looking for reliable and budget-friendly Virtual Private Server (VPS) hosting? Look no further than Dracula Servers. Dracula Servers offers a range of VPS hosting plans tailored to meet diverse needs. With competitive pricing, robust performance, and a user-friendly interface, it’s an excellent choice for individuals and businesses alike.

Explore the Dracula Servers website to discover hosting solutions that align with your requirements and take your online presence to new heights with their affordable and efficient VPS hosting services.

Visit Dracula Servers and experience reliable VPS hosting without breaking the bank.

Step 4: Start and Enable Jenkins Service

Once installed, start the Jenkins service:

Bash

sudo systemctl start jenkins

To ensure Jenkins launches automatically on system boot, use the following command:

Bash

sudo systemctl enable jenkins

Step 5: Verify Jenkins Installation and Access the Web Interface

Now, verify if Jenkins is running by checking its status:

Bash

sudo systemctl status jenkins

The output should indicate that Jenkins is “active (running)”.

Unlocking the Web Interface:

By default, Jenkins runs on port 8080. Access the web interface by opening your web browser and navigating to:

http://localhost:8080

Initial Password Retrieval:

During installation, a temporary password is generated for initial login. Locate the password within the Jenkins log file:

Bash

sudo cat /var/log/jenkins/jenkins.log

Look for a line containing “Initial admin password is”. Copy the password and use it to log in to the Jenkins web interface.

Important Note: This initial password serves as a temporary access key. For security reasons, it’s crucial to change it after your first login.

Step 6: Unlock Jenkins and Customize Your Dashboard

  1. Open your web browser and navigate to http://localhost:8080.
  2. Paste the temporary password retrieved from the log file in the “Password” field and click “Sign in”.

Congratulations! You’ve successfully unlocked the Jenkins web interface. However, the initial setup is not complete.

Customizing the Dashboard:

The default Jenkins dashboard displays basic information. You can personalize it with plugins that extend functionality.

  1. Click on “Manage Jenkins” in the navigation menu on the left.
  2. Select “Manage Plugins” from the available options.
  3. Jenkins offers two ways to install plugins:
    • Available plugins: This tab displays a vast library of plugins categorized by functionality. Browse through the categories, search for specific plugins, and select the ones you desire. Click “Install” next to the chosen plugins.
    • Uploaded plugins: If you have a downloaded plugin file (.hpi), you can upload it in this tab for installation.

Installing Essential Plugins:

Here are some recommended plugins to enhance your Jenkins experience:

  • Git Plugin: Enables integration with Git repositories for version control.
  • Maven Plugin: Integrates with Maven for build automation using Maven commands.
  • Pipeline Plugin: Introduces pipeline as code functionality for defining build and deployment workflows.
  • Build Pipeline Executor Plugin: Provides additional executors for running concurrent builds, increasing efficiency.
  • Jenkins Warnings Plugin: Analyzes build outputs to identify potential issues and display warnings.

Restarting Jenkins:

After installing plugins, it’s essential to restart Jenkins for the changes to take effect:

  1. Go back to the “Manage Jenkins” section.
  2. Click on “Restart Jenkins”.

Creating Your First Job:

Jenkins revolves around “jobs,” which define automated tasks like building, testing, and deploying your software. Here’s a basic example of creating a job:

  1. Go back to the Jenkins dashboard.
  2. Click on “New Item”.
  3. Choose “FreeStyle Project” (suitable for general-purpose builds).
  4. Enter a name for your job (e.g., “My First Job”).
  5. In the “Build” section, you can define the commands or scripts to be executed during the build process. This depends on your specific project requirements.
  6. Click “Save” to create your first job.

Running Your First Job:

  1. Go back to the Jenkins dashboard.
  2. Locate your newly created job.
  3. Click on the “Build Now” button to initiate the job execution.

Monitoring Job Progress:

The Jenkins dashboard displays the progress of your job, including any logs and outputs generated during execution. Analyzing these logs can help identify errors and troubleshoot any issues.

Congratulations! You’ve successfully installed Jenkins on Ubuntu 24.04, unlocked the web interface, and created your first basic job. This provides a strong foundation for automating your development workflow further.

Step 7: Security Considerations and Best Practices

While Jenkins empowers your development process, security remains paramount. Here are some best practices to keep in mind:

  • Strong Initial Password: Change the default temporary password to a strong and unique one after your first login.
  • User Permissions: Implement role-based access control (RBAC) to restrict user permissions within Jenkins, ensuring only authorized users can perform specific actions.
  • Plugin Security: Be cautious when installing plugins. Only install plugins from trusted sources and keep them updated to address potential vulnerabilities.
  • Regular Backups: Regularly back up your Jenkins configuration and job data to minimize data loss in case of unforeseen circumstances.

Beyond the Basics: Exploring Advanced Features

Jenkins offers a vast array of features beyond basic installation and job creation. Here are some areas for further exploration:

  • Pipeline as Code (Pipeline Plugin): Master the concept of pipeline as code to define build and deployment workflows using declarative syntax.
  • Continuous Integration and Delivery (CI/CD): Utilize Jenkins to implement CI/CD pipelines, automating software development life cycle stages.
  • Plugin Ecosystem: Delve into the extensive plugin repository to discover plugins specifically catering to your project’s needs. These plugins can integrate with various tools and services, extending Jenkins functionality.
  • Security Plugins: Explore security-focused plugins that offer features like vulnerability scanning and code signing for enhanced security within your workflow.

By venturing beyond the basics and delving deeper into these features, you can unlock Jenkins’ full potential and establish a robust and automated software development pipeline.

That sums up this guide. Check out More Linux Tutorials Here!

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
× Dracula Servers

Subscribe to DraculaHosting and get exclusive content and discounts on VPS services.