Mets Minor League Blog

Music theory, instruments and musicians

Mets Minor League Blog

Music theory, instruments and musicians

How to Install Jenkins on Ubuntu 24.04 Step-by-Step Guide

How to Install Jenkins on Ubuntu 24.04 Step-by-Step Guide

Automating your software development process is crucial for efficient continuous integration and delivery. Jenkins is one of the most popular open-source automation servers, enabling you to build, test, and deploy your projects seamlessly. Installing Jenkins on Ubuntu 24.04 allows you to set up a robust CI/CD pipeline on your local or server environment, streamlining your development workflow. Before starting, ensure your system is updated and has a stable internet connection. You will also need administrative privileges to install packages and configure services.

What You’ll Need

  • Ubuntu 24.04 installed and running
  • Root or sudo user privileges
  • Stable internet connection
  • Java Development Kit (OpenJDK 11 or newer) (optional, as Jenkins installs its own JDK)

Step-by-Step

  1. Update your system packages: Open a terminal and run:
    sudo apt update && sudo apt upgrade -y

    This ensures all existing packages are up-to-date, reducing compatibility issues during installation.

  2. Add Jenkins repository: First, import the GPG key used to verify package signatures:
    wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -

    Then, add the Jenkins repository to your system sources list:

    sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
  3. Update package lists again: Run:
    sudo apt update

    This refreshes your package cache with the new Jenkins repository.

  4. Install Java (if not already installed): Jenkins requires Java to run. To install OpenJDK 11, run:
    sudo apt install openjdk-11-jdk -y

    Verify the installation:

    java -version

    Ensure the output shows Java 11 or newer.

  5. Install Jenkins: Execute:
    sudo apt install jenkins -y

    This command installs the latest stable Jenkins package from the repository.

  6. Start and enable Jenkins service: Run:
    sudo systemctl start jenkins

    and

    sudo systemctl enable jenkins

    This ensures Jenkins starts on boot and is running now.

  7. Adjust firewall settings: If you have UFW enabled, allow traffic on port 8080, the default Jenkins port:
    sudo ufw allow 8080/tcp

    Verify UFW status:

    sudo ufw status
  8. Access Jenkins Web Interface: Open your browser and navigate to:
    http://your_server_ip:8080

    You will see the Jenkins unlock screen.

  9. Unlock Jenkins: Retrieve the initial admin password:
    sudo cat /var/lib/jenkins/secrets/initialAdminPassword

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

  10. Complete the setup wizard: Follow the on-screen instructions to install recommended plugins and create your admin user account. Once finished, Jenkins is ready for use.

Common Mistakes

  • Skipping system update, leading to package conflicts or outdated dependencies.
  • Not adding the Jenkins repository or GPG key, which causes installation errors.
  • Installing an incompatible Java version; Jenkins requires Java 11 or newer.
  • Forgetting to open firewall ports, making Jenkins inaccessible externally.
  • Not enabling Jenkins service to start on boot, leading to manual start requirements after reboots.

Tips

  • Use a static IP or hostname for your server to avoid IP changes breaking access.
  • Regularly update Jenkins and plugins for security and feature improvements.
  • Configure SSL for secure access, especially if accessible over the internet.
  • Set up backups of your Jenkins configuration and jobs to prevent data loss.
  • Use a dedicated user account for Jenkins to enhance security.

Troubleshooting

If Jenkins does not start or you encounter errors:

  • Check Jenkins status: Run sudo systemctl status jenkins to see if the service is active. If not, review logs with journalctl -u jenkins for errors.
  • Verify Java installation: Ensure Java is installed correctly and the version is compatible. Run java -version.
  • Firewall issues: Confirm port 8080 is open and accessible from your client machine.
  • Initial password not working: Re-check the password in /var/lib/jenkins/secrets/initialAdminPassword. Make sure you’re copying it exactly.
  • Reinstall Jenkins: If issues persist, remove and reinstall Jenkins, ensuring all steps are followed correctly.

Frequently Asked Questions

1. Do I need to install Java separately?

Jenkins requires Java 11 or newer. You can install OpenJDK 11 using sudo apt install openjdk-11-jdk. Alternatively, Jenkins can install its own JDK during setup.

2. Can I run Jenkins on a different port?

Yes, you can change the port by editing the Jenkins configuration file at /etc/default/jenkins and modifying the HTTP_PORT parameter.

3. How secure is Jenkins on Ubuntu 24.04?

Security depends on proper configuration. Use HTTPS, strong passwords, and restrict access to trusted IPs. Keep Jenkins and plugins updated.

4. How do I upgrade Jenkins later?

Run sudo apt update && sudo apt upgrade jenkins. This updates Jenkins to the latest version from the repository.

5. Can I install plugins after setup?

Yes, Jenkins has a built-in plugin manager accessible via the web interface, allowing you to install and update plugins anytime.

6. Is Jenkins suitable for production environments?

Absolutely, but for production, ensure you configure security, backups, SSL, and monitor server health regularly.

By following this comprehensive guide, you will have Jenkins up and running on your Ubuntu 24.04 system, ready to automate your build and deployment processes effectively.

Related

How to Install Jenkins on Ubuntu 24.04 Step-by-Step Guide
Scroll to top