FedoraRHEL Based

How To Install Jenkins on Fedora 42

Install Jenkins on Fedora 41

Jenkins stands as one of the most popular open-source automation servers in the DevOps world, offering powerful continuous integration and continuous delivery (CI/CD) capabilities. For Fedora 42 users, installing and configuring Jenkins properly provides a robust foundation for automating software development workflows. This comprehensive guide walks through every aspect of installing Jenkins on Fedora 42, from preparation to optimization, ensuring you’ll have a fully functional automation server to enhance your development process.

Understanding Jenkins

Jenkins serves as an automation powerhouse that has revolutionized how development teams build, test, and deploy software. Created in 2011, this Java-based open-source application originated as a fork of the Hudson project and quickly gained widespread adoption across the software development community.

At its core, Jenkins acts as the central hub for automating various stages of the software delivery pipeline. It integrates seamlessly with numerous tools and technologies, including version control systems like Git and SVN, build tools such as Maven and Gradle, and testing frameworks like JUnit and Selenium. This extensive integration capability allows teams to create comprehensive workflows that automate previously manual processes.

The key strengths of Jenkins include its:

  • Extensive plugin ecosystem with thousands of options
  • Flexibility to adapt to virtually any development environment
  • Active community support and regular updates
  • Ability to distribute builds across multiple machines
  • Support for pipeline-as-code through Jenkinsfile

By leveraging Jenkins, development teams can dramatically reduce manual intervention, catch bugs earlier in the development cycle, and ensure consistent, repeatable build and deployment processes.

Prerequisites for Installing Jenkins on Fedora 42

Before proceeding with Jenkins installation, ensure your system meets the necessary requirements:

System Requirements:

  • A Fedora 42 server or workstation installation
  • Minimum 1GB RAM (2GB or more recommended for production)
  • At least 50GB free disk space (for Jenkins and build artifacts)
  • Processor with at least 2 cores (more for larger workloads)
  • Network connectivity for package downloads and repository access

Access Requirements:

  • Root access or a user account with sudo privileges
  • SSH access if installing on a remote server

Network Requirements:

  • Outbound internet access for package installation
  • Open port 8080 for Jenkins web interface (configurable)
  • Additional ports if integrating with external systems

Knowledge Prerequisites:

  • Basic Linux command line familiarity
  • Understanding of package management on Fedora
  • Familiarity with system services
  • Basic understanding of CI/CD concepts is helpful but not required

Preparing Your Fedora 42 System

Proper system preparation creates a stable foundation for Jenkins installation. Follow these steps to ensure your Fedora 42 system is ready:

Update System Packages:
First, update all existing packages to their latest versions to ensure security and compatibility:

sudo dnf clean all
sudo dnf update

This command fetches the latest package information from Fedora repositories and installs all available updates. Confirm the installation when prompted by typing “y”.

Install Essential Utilities:
Several utilities will be useful during and after Jenkins installation:

sudo dnf install curl wget git nano unzip

These tools facilitate downloading files, managing source code, and editing configuration files.

Verify System Time:
Jenkins relies on accurate system time for scheduling and timestamps. Verify and configure your system’s time settings:

timedatectl status

If needed, enable time synchronization:

sudo systemctl enable --now chronyd

Create Backup (Optional):
If installing on a system with existing data, consider creating a backup before proceeding:

sudo tar -czf /backup/fedora-system-backup-$(date +%Y%m%d).tar.gz /etc /home

This creates a compressed archive of important system directories.

Installing Java for Jenkins

Jenkins is written in Java and requires a compatible Java runtime environment. The Java version you choose depends on which Jenkins release you’ll be using.

Understanding Java Requirements:

  • Jenkins weekly releases 2.463 (June 2024) and newer: Java 17 or Java 21
  • Jenkins weekly releases 2.419 (August 2023) and newer: Java 11, Java 17, or Java 21
  • Jenkins LTS releases 2.479.1 (October 2024) and newer: Java 17 or Java 21
  • Jenkins LTS releases 2.426.1 (November 2023) and newer: Java 11, Java 17, or Java 21

For Fedora 42, installing OpenJDK 17 is recommended as it’s well-supported by current Jenkins versions:

sudo dnf install java-17-openjdk

Verify Java Installation:
After installation, verify that Java is properly installed and check its version:

java -version

You should see output confirming OpenJDK 17 is installed:

openjdk 17.0.x 2023-xx-xx
OpenJDK Runtime Environment (build 17.0.x+xx)
OpenJDK 64-Bit Server VM (build 17.0.x+xx, mixed mode, sharing)

Setting JAVA_HOME Environment Variable:
Configure the JAVA_HOME environment variable by adding it to the system-wide profile:

echo "export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))" | sudo tee /etc/profile.d/java_home.sh
source /etc/profile.d/java_home.sh

Verify the configuration:

echo $JAVA_HOME

This should display the path to your Java installation directory.

Adding the Jenkins Repository

To ensure you install the official and latest version of Jenkins, you need to add the Jenkins repository to your system:

Import Jenkins GPG Key:
First, import the Jenkins repository GPG key to verify package integrity:

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

Add Jenkins Repository:
Create a new repository configuration file for Jenkins:

sudo dnf config-manager --add-repo https://pkg.jenkins.io/redhat-stable/jenkins.repo

This adds the stable Jenkins repository to your system’s package manager configuration.

Verify Repository Configuration:
Ensure the repository was correctly added:

sudo dnf repolist | grep jenkins

You should see the Jenkins repository listed in the output.

Update Repository Information:
Refresh the package manager’s repository information:

sudo dnf makecache

This ensures that your system has the latest information about available Jenkins packages.

Installing Jenkins

With the repository configured, you can now install Jenkins:

Install Jenkins Package:
Execute the following command to install Jenkins:

sudo dnf install jenkins

This command downloads and installs the latest stable version of Jenkins from the configured repository.

Verify Installation:
After installation completes, verify Jenkins package information:

rpm -qi jenkins

This displays detailed information about the installed Jenkins package, including version number, installation date, and file locations.

Understanding Installation Components:
The Jenkins installation creates:

  • User account: A dedicated ‘jenkins’ system user to run the Jenkins service
  • Home directory: /var/lib/jenkins directory that stores configuration, plugins, and build data
  • Configuration files: Located in /etc/sysconfig/jenkins
  • Log files: Located in /var/log/jenkins/jenkins.log
  • Web application: Jenkins.war file containing the web application

Take note of these locations as you’ll need them for troubleshooting and configuration management.

Configuring and Starting Jenkins Service

Jenkins runs as a system service managed by systemd on Fedora 42. This enables automatic startup and provides easy management through standard systemd commands:

Start Jenkins Service:
Start the Jenkins service with:

sudo systemctl start jenkins

Enable Jenkins Service:
Configure Jenkins to start automatically at system boot:

sudo systemctl enable jenkins

Check Service Status:
Verify that Jenkins is running properly:

sudo systemctl status jenkins

The output should indicate that Jenkins is “active (running)” with no error messages.

Important Service Management Commands:

  • Restart Jenkins: sudo systemctl restart jenkins
  • Stop Jenkins: sudo systemctl stop jenkins
  • View Jenkins logs: sudo journalctl -u jenkins

If the service fails to start, check the logs for error messages:

sudo journalctl -u jenkins -f

This command follows (shows in real-time) the Jenkins service logs, which can help identify startup issues.

Configuring Firewall Settings

For security reasons, Fedora 42 comes with a firewall enabled by default. You need to configure it to allow access to Jenkins:

Check Firewall Status:
First, verify that the firewall is running:

sudo systemctl status firewalld

Open Jenkins Port:
By default, Jenkins runs on port 8080. Configure the firewall to allow access to this port:

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

The first command adds a permanent rule allowing TCP traffic on port 8080, and the second command reloads the firewall configuration to apply the changes.

Verify Firewall Configuration:
Confirm that the port is now open:

sudo firewall-cmd --list-all

Look for port 8080/tcp in the output.

Test Connectivity:
Test that Jenkins is accessible by accessing the web interface using a browser:

http://your_server_ip:8080

Replace “your_server_ip” with your Fedora server’s IP address or hostname. If you’re installing on your local machine, use “localhost” instead.

Initial Jenkins Setup

After installation, Jenkins requires initial configuration through its web interface:

Access Jenkins Web Interface:
Open a web browser and navigate to:

http://your_server_ip:8080

You’ll be greeted with a “Unlock Jenkins” screen requesting an initial administrator password.

Retrieve Initial Admin Password:
The initial password is stored in a file on your server. Retrieve it with:

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

This displays a long alphanumeric string that serves as your initial administrator password. Copy this password and paste it into the web interface.

Install Jenkins on Fedora 41

Installation Wizard:
After unlocking Jenkins, you’ll proceed through a setup wizard:

  1. When asked to “Customize Jenkins,” choose either:
    • “Install suggested plugins” (recommended for beginners)
    • “Select plugins to install” (for advanced customization)
  2. Wait for plugin installation to complete. This may take several minutes depending on your internet connection speed.
  3. Create your first administrator user by filling in:
    • Username
    • Password
    • Full name
    • Email address
  4. Configure the Jenkins URL. The wizard will suggest a default URL based on your server address. Review and adjust if necessary.
  5. Click “Save and Finish” to complete the initial setup.

After completing these steps, you’ll see a “Jenkins is ready!” message and can start using your Jenkins installation.

Jenkins Configuration Essentials

Understanding key configuration aspects helps you maintain and optimize your Jenkins installation:

Jenkins Home Directory:
The Jenkins home directory (/var/lib/jenkins by default) contains:

  • config.xml: Main configuration file
  • jobs/: Directory containing job configurations
  • plugins/: Directory containing installed plugins
  • users/: Directory containing user accounts and settings
  • workspace/: Directory where builds are executed

Important Configuration Files:

  • /etc/sysconfig/jenkins: System-level configuration including Java options, port settings, and user permissions
  • /var/lib/jenkins/config.xml: Jenkins core configuration
  • /var/lib/jenkins/jenkins.model.JenkinsLocationConfiguration.xml: Contains URL and admin email settings

System Configuration:
Navigate to “Manage Jenkins” → “Configure System” to access Jenkins system configuration. Here you can configure:

  • System message
  • Number of executors
  • Jenkins URL
  • Email notification settings
  • Global properties and environment variables
  • Plugin-specific configuration

Global Tool Configuration:
Navigate to “Manage Jenkins” → “Global Tool Configuration” to set up tools like:

  • JDK installations
  • Git installations
  • Maven installations
  • Gradle installations

These tools are used by jobs to build and test software.

Setting Up Your First Jenkins Job

Creating a simple job helps verify your Jenkins installation and provides a practical understanding of Jenkins functionality:

Create a New Job:

  1. From the Jenkins dashboard, click “New Item”
  2. Enter a name for your job (e.g., “First-Test-Job”)
  3. Select “Freestyle project” and click “OK”

Job Types Explained:

  • Freestyle project: Simple, single-task job
  • Pipeline: Defines your build pipeline as code
  • Multi-configuration project: For testing across multiple environments
  • Folder: Organizes related jobs together
  • GitHub Organization: Automatically creates jobs for repositories in a GitHub organization

Configure Build Triggers:
In the job configuration page, scroll to the “Build Triggers” section and select one of:

  • Build periodically: Uses cron syntax to schedule builds
  • Poll SCM: Periodically checks for source code changes
  • GitHub hook trigger: Builds when changes are pushed to GitHub

Add Build Steps:
Scroll to the “Build” section and click “Add build step.” For a simple test:

  1. Select “Execute shell”
  2. Enter a simple command like: echo "Hello, Jenkins is working!"

Configure Post-Build Actions:
Scroll to “Post-build Actions” and click “Add post-build action.” Common options include:

  • Archive artifacts
  • Build other projects
  • Email notification
  • Publish JUnit test results

Save and Run:
Click “Save” to create your job, then click “Build Now” to execute it. View the build results by clicking on the build number in the build history and selecting “Console Output”.

Troubleshooting Common Installation Issues

Even with careful installation, you may encounter issues. Here are solutions to common problems:

Java-Related Problems:

  • Issue: Jenkins fails to start with Java errors.
  • Solution: Verify Java installation and version compatibility:
    java -version

    Ensure the version matches Jenkins requirements. If needed, install a compatible version.

Repository and Package Installation Issues:

  • Issue: Repository key import fails.
  • Solution: Verify internet connectivity and try an alternative method:
    curl --silent --location http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo | sudo tee /etc/yum.repos.d/jenkins.repo
  • Issue: Package installation fails with dependency errors.
  • Solution: Update package lists and try again:
    sudo dnf clean all
    sudo dnf makecache
    sudo dnf install jenkins

Service Startup Failures:

  • Issue: Jenkins service fails to start.
  • Solution: Check logs for specific errors:
    sudo journalctl -u jenkins -f
  • Issue: “No JSP Support” errors in logs.
  • Solution: Install Jetty JSP support:
    sudo dnf install jetty-jsp

Permission Problems:

  • Issue: Jenkins cannot access required directories.
  • Solution: Verify and fix permissions:
    sudo chown -R jenkins:jenkins /var/lib/jenkins
    sudo chmod -R 755 /var/lib/jenkins

Web Interface Access Issues:

  • Issue: Cannot access Jenkins web interface.
  • Solution: Check firewall configuration:
    sudo firewall-cmd --list-all

    Ensure port 8080 is open. Also verify Jenkins is running:

    sudo systemctl status jenkins
  • Issue: “This site can’t be reached” error in browser.
  • Solution: Verify Jenkins is running on the expected port:
    sudo netstat -tulpn | grep jenkins

    If Jenkins is running on a different port, adjust your browser URL accordingly.

Performance Tuning and Optimization

Optimizing Jenkins performance ensures efficient operation, especially for larger installations:

Memory Allocation:
Jenkins performance heavily depends on available memory. Adjust Java heap settings in /etc/sysconfig/jenkins:

JENKINS_JAVA_OPTIONS="-Xmx2g -Xms512m"

This allocates 2GB maximum and 512MB initial heap memory. Adjust based on your server’s available RAM.

Optimizing Jenkins for Better Performance:

  • Install the “Performance Plugin” to monitor build times and resource usage
  • Configure proper executor counts based on server capacity:
    • Navigate to “Manage Jenkins” → “Configure System”
    • Set “# of executors” to the number of CPU cores minus one for optimal performance

Cleaning Up Old Builds and Artifacts:
Configure job-specific retention policies:

  1. In job configuration, find “Discard old builds”
  2. Enable and set “Max # of builds to keep” and “Days to keep builds”

For global cleanup, install the “Disk Usage Plugin” and configure regular cleanup tasks.

Managing Disk Space:
Monitor disk usage through “Manage Jenkins” → “System Information” and consider:

  • Archiving less frequently needed artifacts to external storage
  • Implementing workspace cleanup after builds
  • Rotating and compressing log files regularly

Scheduling Background Tasks:
Configure less critical operations during off-hours:

  1. Navigate to “Manage Jenkins” → “Configure System”
  2. Find “Quiet Period” and adjust according to your needs
  3. Use the “Periodic Background Task” section to schedule maintenance activities.

Jenkins Security Best Practices

Securing your Jenkins installation protects both your automation server and the systems it interacts with:

Securing Your Jenkins Installation:

  • Keep Jenkins and plugins updated to the latest stable versions
  • Run Jenkins behind a reverse proxy with SSL/TLS encryption
  • Configure Jenkins to use HTTPS instead of HTTP
  • Remove unnecessary plugins and features to reduce attack surface
  • Set appropriate file permissions on the Jenkins home directory

User Management and Authentication:

  • Disable anonymous access if not required
  • Use the “Matrix-based security” system for fine-grained permissions
  • Integrate with LDAP or Active Directory for centralized authentication
  • Implement multi-factor authentication using the appropriate plugin
  • Enforce strong password policies

Authorization Strategies:

  1. Navigate to “Manage Jenkins” → “Configure Global Security”
  2. Under “Authorization,” select an appropriate strategy:
    • Matrix-based security: Detailed permission control for each user
    • Project-based Matrix Authorization: Extends matrix security to job level
    • Role-based Authorization Strategy: For managing security through roles

Securing Jenkins with HTTPS:

  1. Generate or obtain SSL certificates
  2. Configure Jenkins to use HTTPS by editing the /etc/sysconfig/jenkins file:
    JENKINS_ARGS="--httpPort=-1 --httpsPort=8443 --httpsKeyStore=/path/to/keystore --httpsKeyStorePassword=password"
  3. Restart Jenkins to apply changes

Regular Security Updates:

  • Subscribe to the Jenkins security mailing list
  • Implement an audit trail for monitoring system activities:
    1. Install the “Audit Trail Plugin”
    2. Configure logging options through “Manage Jenkins” → “Configure System” → “Audit Trail”
  • Schedule regular security scans of your Jenkins environment
  • Document security policies and procedures for consistent application

Congratulations! You have successfully installed Jenkins. Thanks for using this tutorial for installing Jenkins on Fedora 42 Linux system. For additional help or useful information, we recommend you check the 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