How to Install Jenkins on Linux, Windows, and macOS

Table of Contents

1. What is Jenkins?

Jenkins is an open-source automation server that facilitates the automation of various stages in the software development lifecycle, including building, testing, and deploying applications. It is widely recognized as a leading tool for implementing Continuous Integration (CI) and Continuous Delivery (CD) pipelines.

Jenkins helps development teams to integrate code changes frequently, automatically test them, and rapidly deliver high-quality software, thereby reducing integration issues and accelerating the release process.

Key Benefits:

2. Prerequisites (Java)

Jenkins is a Java-based application, so a compatible Java Development Kit (JDK) is required. As of recent Jenkins versions, **OpenJDK 11 or OpenJDK 17** are recommended.

A. Check for Java Installation:

Open your terminal or command prompt and run:

java -version

If Java is installed, you'll see version information. If not, or if it's an incompatible version (e.g., Java 8), you need to install or update it.

B. Install Java (OpenJDK 17 Recommended):

3. Installation Methods Overview

Jenkins can be installed in several ways. We'll cover direct OS installation and a popular containerized method.

4. Install on Linux (Ubuntu/Debian)

This method uses the `apt` package manager for a system-wide installation.

A. Add Jenkins Repository Key:

sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
  https://pkg.jenkins.io/debian-stable/jenkins-keyring.asc

B. Add Jenkins Repository to Sources:

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

C. Update Package Cache & Install Jenkins:

sudo apt update
sudo apt install -y jenkins

D. Start and Check Jenkins Service:

Jenkins should start automatically after installation.

sudo systemctl start jenkins
sudo systemctl status jenkins
# Expected output will show 'active (running)'

E. Adjust Firewall (if UFW is active):

sudo ufw allow 8080 # Jenkins default port
sudo ufw enable     # Enable firewall if it's not already
sudo ufw status     # Verify the rule is active

Jenkins will be accessible at `http://:8080`.

5. Install on Linux (Red Hat/CentOS/Fedora)

This method uses the `dnf` package manager (or `yum` for older CentOS/RHEL versions).

A. Add Jenkins Repository:

sudo wget -O /etc/yum.repos.d/jenkins.repo \
    https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key

B. Install Jenkins:

sudo dnf install -y jenkins # Use 'sudo yum install -y jenkins' for older systems

C. Start and Enable Jenkins Service:

sudo systemctl start jenkins
sudo systemctl enable jenkins
sudo systemctl status jenkins
# Expected output will show 'active (running)'

D. Adjust Firewall (if Firewalld is active):

sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp # Allow HTTP access
sudo firewall-cmd --reload # Apply changes

Jenkins will be accessible at `http://:8080`.

6. Install on Windows

Jenkins provides a native Windows installer (MSI).

A. Download Jenkins MSI Installer:

Go to the official Jenkins website: jenkins.io/download/lts/windows/ and download the LTS installer.

B. Run the Installer:

  1. Double-click the downloaded `.msi` file.
  2. The Jenkins Setup Wizard will appear. Click **Next**.
  3. Choose the **Destination Folder** for Jenkins (default is usually fine). Click **Next**.
  4. Service Logon Type:
    • `Run service as LocalSystem (less secure)`: Easiest, but gives Jenkins broad system privileges.
    • `Run service as a local or domain user (recommended)`: More secure. You'll need to create a dedicated local Windows user (e.g., `jenkins`) and grant it necessary permissions (e.g., "Log on as a service" right in Local Security Policy). This is recommended for production.
    Choose the option that suits your needs for now (LocalSystem for quick testing). Click **Next**.
  5. Port Selection: Default is `8080`. You can test it. If it conflicts, change it. Click **Test Port** to check availability. Click **Next**.
  6. Java Home Directory: The installer should auto-detect your JDK. If not, click **Browse** and point it to your JDK 11/17 root directory (e.g., `C:\Program Files\Java\jdk-17`). Click **Next**.
  7. Click **Install**.
  8. Click **Finish**.

Jenkins should start automatically after installation. You can access it at `http://localhost:8080` (or your chosen port).

You can also manage the Jenkins service via `services.msc` (search in Windows Start Menu).

7. Install on macOS

The recommended way to install Jenkins on macOS is using Homebrew.

A. Install Homebrew (if not already installed):

Open Terminal.app (Finder > Applications > Utilities > Terminal) and run:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Follow the on-screen instructions to complete the Homebrew installation.

B. Install Jenkins via Homebrew:

brew install jenkins-lts

C. Start Jenkins Service:

# Start Jenkins (will launch automatically on login)
brew services start jenkins-lts

# Check status
brew services list # Look for jenkins-lts status

Jenkins will be accessible at `http://localhost:8080`.

Note: macOS Gatekeeper might initially block Jenkins. If prompted, go to System Settings > Privacy & Security > General and click "Open Anyway" for Jenkins.

8. Initial Jenkins Setup Wizard (All OS)

After Jenkins starts for the first time, you'll be redirected to a web-based setup wizard in your browser (at `http://:8080`).

A. Unlock Jenkins:

The first screen will ask for an administrator password. Retrieve it from your server's initial admin password file:

Paste the password into the browser field and click **Continue**.

B. Install Plugins:

Jenkins will proceed to download and install the selected plugins. This might take several minutes.

C. Create First Admin User:

Once plugins are installed, you'll be prompted to create your first administrator user. Fill in all the fields (Username, Password, Full Name, Email Address). **Remember these credentials!**

D. Instance Configuration:

Confirm your Jenkins URL. The default (`http://localhost:8080`) is usually fine for local setups. For servers, ensure it's your server's public IP or hostname. Click **Save and Finish**.

E. Jenkins Dashboard:

You'll now be redirected to the Jenkins dashboard. Your Jenkins instance is ready!

9. Post-Installation Steps

A. Install Recommended Tools:

Depending on your projects, you'll need build tools (Maven, Gradle, npm), SCM clients (Git), etc., on your Jenkins server or agents.

B. Explore Plugins:

Jenkins' power comes from its plugins. Explore the marketplace for plugins relevant to your workflow.

Jenkins Dashboard > Manage Jenkins > Plugins

C. Configure Security (Advanced):

For production environments, enhance security beyond the initial setup:

10. Troubleshooting Common Issues

Your CI/CD Automation Journey Begins!

Installing Jenkins is the first step towards automating your software delivery pipelines. While the initial setup might seem daunting, mastering Jenkins will significantly improve your team's efficiency and ability to deliver high-quality software faster. Keep experimenting with different job types, plugins, and integrations to unlock its full potential!