CentOSRHEL Based

How To Install Jenkins on CentOS Stream 10

Install Jenkins on CentOS Stream 10

In this tutorial, we will show you how to install Jenkins on CentOS Stream 10. Jenkins is a powerful tool for automating software development processes, offering a robust platform for Continuous Integration (CI) and Continuous Deployment (CD). It is widely used in the software industry due to its flexibility, scalability, and extensive plugin ecosystem. In this article, we will guide you through the process of installing Jenkins on CentOS Stream 10, a stable and reliable Linux distribution that provides a solid foundation for running Jenkins.

Introduction to Jenkins and CentOS Stream 10

Jenkins is a Java-based application, which means it requires a Java Development Kit (JDK) to be installed on your system. CentOS Stream 10, with its stable and rolling updates, is an excellent choice for hosting Jenkins, as it ensures that your system remains up-to-date with the latest security patches and software versions.

Why Choose CentOS Stream 10 for Jenkins?

  • Stability and Support: CentOS Stream 10 offers a balance between stability and the latest software updates, making it ideal for production environments.
  • Community Support: It benefits from a large community of users and developers, ensuring there are plenty of resources available for troubleshooting and optimization.
  • Compatibility: CentOS Stream 10 is compatible with a wide range of software applications, including Jenkins, due to its adherence to Red Hat Enterprise Linux (RHEL) standards.

Prerequisites for Installing Jenkins

Before you begin the installation process, ensure your system meets the necessary prerequisites.

Hardware Requirements

Jenkins requires at least 256 MB of RAM and 1 GB of disk space for basic operations. However, for a more robust setup, especially if you plan to run multiple jobs or use Docker containers, consider the following:

  • Recommended RAM: 4 GB or more.
  • Recommended Disk Space: 50 GB or more.

Software Requirements

  1. Java: Jenkins requires Java to run. You can install OpenJDK, which is a popular choice for Jenkins installations.
  2. Internet Connection: Ensure you have an active internet connection to download the necessary packages.

Step-by-Step Installation Guide

Step 1: Update CentOS Stream 10

To ensure your system is up-to-date, run the following command in your terminal:

sudo dnf update

This command updates all packages to their latest versions, which is crucial for maintaining system stability and security.

Step 2: Install Java

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

sudo dnf install java-17-openjdk

Verify that Java has been installed correctly by checking its version:

java --version

Step 3: Add Jenkins Repository

Jenkins is not included in the default CentOS repositories. You need to add the Jenkins repository manually:

sudo curl -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo

Step 4: Import GPG Key

To ensure the authenticity of the Jenkins package, import the GPG key:

sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

Step 5: Install Jenkins

Now, you can install Jenkins using the following command:

sudo dnf install jenkins

Step 6: Configure Jenkins Service

To ensure Jenkins listens on all interfaces, you may need to edit its configuration. However, for most setups, the default configuration is sufficient. If you need to make changes, you can edit the service file:

sudo systemctl edit jenkins

Add the following lines to the [Service] section to set the Java command and listening address:

[Service]
Environment="JENKINS_JAVA_CMD=/etc/alternatives/java"
Environment="JENKINS_LISTEN_ADDRESS=0.0.0.0"

Save and exit the editor.

Step 7: Start and Enable Jenkins Service

Start the Jenkins service and enable it to run on boot:

sudo systemctl start jenkins
sudo systemctl enable jenkins

Step 8: Verify Jenkins Service Status

Check if the Jenkins service is running correctly:

sudo systemctl status jenkins

Step 9: Configure Firewall Rules

If your server uses a firewall, you need to allow Jenkins traffic. Open port 8080 (the default Jenkins port):

sudo firewall-cmd --add-port=8080/tcp --permanent
sudo firewall-cmd --reload

Step 10: Retrieve Initial Admin Password

To access Jenkins for the first time, retrieve the initial admin password:

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

Install Jenkins on CentOS Stream 10

Step 11: Access and Set Up Jenkins

  1. Access Jenkins: Open a web browser and navigate to http://your-server-ip:8080.
  2. Unlock Jenkins: Enter the initial admin password.
  3. Install Suggested Plugins: Choose to install the recommended plugins for a basic setup.
  4. Create Admin User: Set up your admin user account.
  5. Set Jenkins URL: Optionally, configure the Jenkins URL to match your server’s domain or IP.
  6. Start Using Jenkins: Click “Start using Jenkins” to complete the setup.

Advanced Configuration Options

Customizing Jenkins URL

If you want to change the default Jenkins URL, you can do so during the initial setup or later by editing the Jenkins configuration file:

  1. Access Jenkins and go to Manage Jenkins > Configure System.
  2. Find the Jenkins URL field and update it with your desired URL.
  3. Save and restart the Jenkins service if necessary.

Using Different Ports

To use a different port (e.g., 9090), edit the Jenkins service configuration:

  1. Edit the Jenkins service file:
sudo systemctl edit jenkins
  1. Add or modify the JENKINS_PORT environment variable:
[Service]
Environment="JENKINS_PORT=9090"
  1. Reload systemd and restart the Jenkins service:
sudo systemctl daemon-reload
sudo systemctl restart jenkins
  1. Update firewall rules if necessary:
sudo firewall-cmd --add-port=9090/tcp --permanent
sudo firewall-cmd --reload

Securing Jenkins with SSL/TLS

To secure your Jenkins instance with HTTPS, you can use a reverse proxy server like NGINX:

  1. Install NGINX:
    sudo dnf install nginx
  2. Generate SSL Certificates (e.g., using Let’s Encrypt):
    sudo dnf install certbot python3-certbot-nginx
    sudo certbot --nginx -d yourdomain.com
  3. Configure NGINX as a Reverse Proxy: Edit the NGINX configuration file (/etc/nginx/nginx.conf or a site-specific file in /etc/nginx/conf.d/) to include:
    server {
            listen 443 ssl;
            server_name yourdomain.com;
    
            ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
            ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
    
            location / {
                proxy_pass http://localhost:8080;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
            }
        }
        
  4. Restart NGINX:
    sudo systemctl restart nginx

Troubleshooting Common Issues

Jenkins Service Not Starting

  • Check Service Status: Use sudo systemctl status jenkins to identify any errors.
  • Journalctl Logs: Inspect detailed logs with sudo journalctl -u jenkins.
  • Java Version Compatibility: Ensure you are using a compatible Java version.

Firewall Issues

  • Check Firewall Rules: Verify that Jenkins’ port is open using sudo firewall-cmd --list-all.
  • Temporary Allowance: Temporarily disable the firewall to test if it’s blocking Jenkins.

Java Version Compatibility

  • Check Java Version: Run java --version to ensure you are using a supported version.
  • Update Java: If necessary, update Java to a compatible version.

Congratulations! You have successfully installed Jenkins. Thanks for using this tutorial for installing Jenkins on your CentOS Stream 10 system. For additional help or useful information, we recommend you check the official Jenkins website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button