How to Install Jenkins on Windows

How to Install Jenkins on Windows

Plenty of teams I’ve worked with are Windows-first shops — .NET applications, Windows-specific build tools, or just an existing infrastructure investment in Windows Server. Jenkins runs perfectly well on Windows, and in this guide, I’ll walk through installing it, configuring it as a Windows service, and getting your first build running.

Why Run Jenkins on Windows?

The most common reason is building Windows-native applications — .NET Framework or .NET Core/5+ apps, Windows desktop applications (WPF, WinForms), or anything requiring MSBuild, Visual Studio’s build tools, or PowerShell-based automation that’s simplest to run natively on Windows rather than through compatibility layers on Linux.

Jenkins Architecture on Windows

Jenkins works the same way regardless of OS — a controller schedules jobs, agents execute them. On Windows, Jenkins typically runs as a Windows Service, which keeps it running in the background even without an active user login, restarting automatically if the machine reboots.

Prerequisites

  • Windows 10/11 or Windows Server 2019/2022
  • At least 4GB RAM (8GB+ recommended for heavier workloads)
  • Java 17 or 21 (check current Jenkins requirements before installing)
  • Administrator access to install software and configure services

Step 1: Install Java

Download a supported JDK (Eclipse Temurin is a popular free choice) from https://adoptium.net/ and run the installer, or install via the command line if you have a package manager like Chocolatey:

choco install temurin17 -y

Verify the installation:

java -version

Step 2: Download the Jenkins Windows Installer

Go to the official Jenkins download page and grab the Windows installer (.msi file), or use Chocolatey:

choco install jenkins -y

If installing manually via the .msi file:

  1. Double-click the downloaded installer.
  2. Choose an installation directory (default: C:\Program Files\Jenkins).
  3. The installer automatically configures Jenkins to run as a Windows Service under a dedicated service account.

Step 3: Start Jenkins

If installed via the .msi, Jenkins starts automatically as a service. You can verify and manage it through the Services app:

Get-Service Jenkins

Or start/stop/restart manually:

Start-Service Jenkins
Stop-Service Jenkins
Restart-Service Jenkins

Step 4: Access Jenkins and Unlock It

Open a browser and navigate to http://localhost:8080. Retrieve the initial admin password from:

C:\Program Files\Jenkins\secrets\initialAdminPassword

Or via PowerShell:

Get-Content "C:\Program Files\Jenkins\secrets\initialAdminPassword"

Paste this into the setup wizard, then choose “Install suggested plugins.”

Step 5: Create Your Admin Account

Follow the wizard to create your first admin user and confirm the Jenkins instance URL.

Step 6: Install Build Tools for Windows Projects

Depending on your project type, install the relevant tooling directly on the machine (or a dedicated Windows agent):

For .NET projects:

choco install dotnet-sdk -y
dotnet --version

For MSBuild/Visual Studio Build Tools:

choco install visualstudio2022buildtools -y

For Git:

choco install git -y

Step 7: Configure a Windows-Based Jenkinsfile

Here’s a complete example for a .NET project running on a Windows agent:

pipeline {
    agent { label 'windows' }

    stages {
        stage('Checkout') {
            steps {
                git branch: 'main', url: 'https://github.com/yourusername/your-dotnet-app.git'
            }
        }

        stage('Restore') {
            steps {
                bat 'dotnet restore'
            }
        }

        stage('Build') {
            steps {
                bat 'dotnet build --configuration Release'
            }
        }

        stage('Test') {
            steps {
                bat 'dotnet test --logger "trx;LogFileName=results.trx"'
            }
        }

        stage('Publish') {
            steps {
                bat 'dotnet publish -c Release -o publish'
                archiveArtifacts artifacts: 'publish/**', fingerprint: true
            }
        }
    }

    post {
        always {
            mstest testResultsFile: '**/results.trx'
        }
    }
}

Notice the use of bat instead of sh for shell steps — Windows agents execute build steps via Windows batch commands (or powershell for PowerShell scripts) rather than Unix shell syntax.

Step 8: Using PowerShell in Pipelines

For more complex scripting, use the powershell step instead of bat:

stage('Custom Script') {
    steps {
        powershell '''
        Write-Host "Running custom deployment script"
        $env:BUILD_ENV = "production"
        .\\scripts\\deploy.ps1
        '''
    }
}

Step 9: Configuring Windows Firewall

If Jenkins needs to be accessed from other machines on your network, allow inbound traffic on port 8080:

New-NetFirewallRule -DisplayName "Jenkins" -Direction Inbound -Protocol TCP -LocalPort 8080 -Action Allow

Step 10: Setting Up a Reverse Proxy with IIS (Optional, Recommended for Production)

For production deployments, it’s common to place Jenkins behind IIS with the Application Request Routing (ARR) module configured as a reverse proxy, allowing HTTPS termination and a cleaner URL structure — similar in concept to using Nginx on Linux.

Step 11: Connecting Additional Windows Agents

For scaling builds, connect additional Windows machines as agents:

  1. On the controller, go to Manage Jenkins > Nodes > New Node, name it, and select “Permanent Agent.”
  2. Set remote root directory (e.g., C:\Jenkins\agent).
  3. Choose “Launch agent by connecting it to the controller” (JNLP), then download and run the agent JAR on the target Windows machine:
java -jar agent.jar -url http://your-jenkins-controller:8080/ `
  -secret <secret-from-node-config> -name "windows-agent-1" `
  -workDir "C:\Jenkins\agent"

Consider installing this as a Windows Service too (using tools like NSSM) so it reconnects automatically after a reboot.

Real-World Deployment Scenario

A pattern I’ve used for a Windows-heavy engineering team:

  1. Jenkins controller runs as a Windows Service on a dedicated Windows Server VM.
  2. A separate Windows agent, equipped with Visual Studio Build Tools and .NET SDKs, handles all build execution.
  3. IIS with ARR reverse-proxies HTTPS traffic to Jenkins’ internal port.
  4. Builds produce NuGet packages and MSI installers, archived as build artifacts and later deployed via a scheduled PowerShell-based release pipeline.

Running Jenkins Inside Windows Subsystem for Linux (WSL2)

An alternative worth considering: if your team primarily needs Linux-style tooling but you’re on a Windows machine, you can run Jenkins inside WSL2 instead of natively on Windows. This gives you access to the full Linux Jenkins ecosystem (Docker, Linux-native plugins) while still running on Windows hardware:

wsl --install -d Ubuntu-24.04

Once inside the WSL2 Ubuntu environment, follow the standard Linux installation steps. This approach is especially useful if you need Docker-based agents but don’t want to manage a separate Linux VM.

Configuring Jenkins Service Recovery Options

By default, if the Jenkins Windows Service crashes unexpectedly, Windows won’t automatically restart it unless configured to do so. Set recovery options via PowerShell:

sc.exe failure Jenkins reset= 86400 actions= restart/60000/restart/60000/restart/60000

This tells Windows to attempt restarting the Jenkins service after a 60-second delay, up to the failure count reset window of 24 hours, significantly improving uptime without manual intervention.

Using Group Policy for Enterprise Windows Agent Deployment

In larger Windows-centric organizations, IT teams often use Group Policy Objects (GPOs) to push the Jenkins agent installation and configuration to multiple build machines simultaneously, rather than manually installing on each one. This pairs well with tools like NSSM (Non-Sucking Service Manager) to wrap the Jenkins agent JAR as a proper Windows Service across the fleet.

Troubleshooting Common Windows Installation Issues

  • Jenkins service won’t start: Check the Windows Event Viewer under Application logs, or Jenkins’ own log file at C:\Program Files\Jenkins\jenkins.err.log.
  • “java: command not found” during builds: Verify Java is added to the system PATH, and that the Jenkins service account (not just your personal user account) can see it.
  • Long file path errors during Git checkout: Enable long path support in Windows and configure Git with git config --system core.longpaths true.
  • Permission errors accessing workspace directories: Confirm the Jenkins service account has full control over its configured workspace and remote root directories.

Security Best Practices

  • Run the Jenkins Windows Service under a dedicated, low-privilege service account rather than a full administrator account.
  • Enable HTTPS via a reverse proxy (IIS/ARR or Nginx via WSL) rather than exposing raw HTTP.
  • Regularly apply Windows security updates in addition to keeping Jenkins and plugins current.
  • Restrict inbound firewall rules to only the necessary ports and trusted network ranges.

FAQs

Q: Can I run Jenkins on Windows and still build Linux/Docker-based projects? Not directly without WSL2 or a separate Linux agent — Docker containers on native Windows require either Docker Desktop with WSL2 backend or a dedicated Linux machine as a separate agent.

Q: Is the .msi installer or Chocolatey the better installation method? Both work well; Chocolatey is convenient for scripted, repeatable installs across multiple machines, while the .msi is straightforward for a single manual setup.

Q: How do I update Jenkins on Windows? Download the latest .msi and run it again (it will upgrade an existing install), or use choco upgrade jenkins if installed via Chocolatey.

Q: Can a Windows Jenkins controller manage Linux agents, and vice versa? Yes — Jenkins’ controller-agent architecture is OS-agnostic. A Windows controller can dispatch jobs to Linux agents (and macOS agents) as long as the network connectivity and agent configuration are set up correctly.

Summary

Installing Jenkins on Windows is straightforward, whether through the official .msi installer or Chocolatey, and running it as a Windows Service ensures it stays available across reboots. For teams building .NET or other Windows-native applications, this setup — combined with dedicated Windows agents equipped with the right build tools — gives you a fully automated CI/CD pipeline tailored to the Windows ecosystem.

References

Total
1
Shares

Leave a Reply

Previous Post
How to Use the NOTIFY Command in PostgreSQL

How to Use the NOTIFY Command in PostgreSQL

Next Post
How to Install Jenkins on Linux

How to Install Jenkins on Linux

Related Posts