How to Install Jenkins on Windows Server 2012 R2

Jenkins is one of the most widely adopted open-source automation servers in the industry, enabling organizations to build, test, and deploy software with repeatable, auditable pipelines. On Windows Server 2012 R2, Jenkins runs as a Windows service on top of the Java Runtime Environment, integrating naturally with PowerShell, MSBuild, and the broader Microsoft toolchain. This guide walks through a complete production-grade Jenkins installation, covering Java prerequisites, service configuration, firewall rules, initial setup, and pipeline verification.

Prerequisites

Before beginning, confirm the following on your Windows Server 2012 R2 host:

  • A local administrator account or domain account with local admin rights
  • At minimum 2 GB RAM dedicated to Jenkins (4 GB recommended for active pipelines)
  • 20 GB of free disk space for the Jenkins home directory and workspace caches
  • Outbound internet access to download installers, or pre-staged files on a share
  • PowerShell 4.0 (included with WS2012 R2 by default)
  • Chocolatey installed (recommended for Java installation — see the Chocolatey tutorial in this series)

Step 1: Install Java Runtime Environment

Jenkins requires Java 11 or Java 17 for modern LTS releases. Java 8 is also supported on older Jenkins versions but is not recommended for new deployments. Use Chocolatey to install the Temurin (Eclipse OpenJDK) distribution, which provides long-term supported builds for Windows:

choco install temurin17 -y

If Chocolatey is not available, download the MSI installer from adoptium.net and install silently:

msiexec /i OpenJDK17U-jdk_x64_windows_hotspot_17.0.11_9.msi /quiet ADDLOCAL=FeatureMain INSTALLDIR="C:Javajdk-17"

After installation, set the JAVA_HOME system environment variable and append the bin directory to the system PATH:

[System.Environment]::SetEnvironmentVariable("JAVA_HOME","C:Program FilesEclipse Adoptiumjdk-17.0.11.9-hotspot","Machine")
$path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
[System.Environment]::SetEnvironmentVariable("Path","$path;C:Program FilesEclipse Adoptiumjdk-17.0.11.9-hotspotbin","Machine")

Open a new PowerShell window and verify Java is visible:

java -version

Step 2: Download and Install Jenkins

Download the latest Jenkins LTS Windows installer from the Jenkins project. The MSI installer creates a Windows service automatically:

Invoke-WebRequest -Uri "https://get.jenkins.io/windows-stable/latest" -OutFile "C:Tempjenkins.msi"

Run the installer. Accept the default installation path of C:Program FilesJenkins and choose to install Jenkins as a Windows service running under the LocalSystem account (or a dedicated service account for production):

msiexec /i "C:Tempjenkins.msi" /quiet /l* "C:Tempjenkins_install.log"

If you prefer a dedicated low-privilege service account (strongly recommended for production), create the account first:

net user jenkins_svc P@ssw0rdStr0ng! /add /comment:"Jenkins Service Account"
net localgroup Administrators jenkins_svc /add

Then modify the service logon after installation:

$svc = Get-WmiObject Win32_Service -Filter "Name='Jenkins'"
$svc.Change($null,$null,$null,$null,$null,$null,".jenkins_svc","P@ssw0rdStr0ng!",$null,$null,$null)

Step 3: Configure Jenkins Home Directory

By default, the Jenkins home directory (JENKINS_HOME) is set to C:WindowsSystem32configsystemprofileAppDataLocalJenkins.jenkins, which is inconvenient for backups and management. Redirect it to a dedicated volume:

New-Item -ItemType Directory -Path "D:JenkinsHome" -Force
[System.Environment]::SetEnvironmentVariable("JENKINS_HOME","D:JenkinsHome","Machine")

Edit the Jenkins service configuration file at C:Program FilesJenkinsjenkins.xml to add the JENKINS_HOME environment variable inside the <env> block, then restart the service:

Restart-Service Jenkins

Step 4: Open Firewall Port

Jenkins listens on TCP port 8080 by default. Create an inbound firewall rule:

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

For production environments, consider placing Jenkins behind IIS as a reverse proxy and only allowing port 8080 from the IIS server’s internal IP. You can also change the Jenkins port by editing jenkins.xml and modifying the --httpPort argument in the service arguments string.

Step 5: Initial Jenkins Setup

Open a browser and navigate to http://localhost:8080. Jenkins will display the Unlock Jenkins screen requesting the initial administrator password. Retrieve it from:

Get-Content "D:JenkinsHomesecretsinitialAdminPassword"

Paste the password into the web interface. On the next screen, select “Install suggested plugins.” Jenkins will install the most commonly needed plugins including Git, Pipeline, GitHub integration, and credentials management. This requires internet access; in air-gapped environments, download plugins manually from plugins.jenkins.io as HPI files.

After plugin installation completes, create the first admin user account. Use a strong password and record the credentials securely. Jenkins does not enforce password complexity by default — consider installing the Matrix Authorization Strategy plugin and enabling the Active Directory security realm for enterprise environments.

Step 6: Create and Verify a Test Pipeline

From the Jenkins dashboard, click New Item, enter a name such as “test-pipeline,” select Pipeline, and click OK. In the Pipeline section, enter the following Declarative Pipeline script to confirm PowerShell integration works:

pipeline {
    agent any
    stages {
        stage('Verify Environment') {
            steps {
                powershell '''
                    Write-Host "Jenkins node: $env:COMPUTERNAME"
                    Write-Host "PowerShell version: $($PSVersionTable.PSVersion)"
                    Write-Host "Jenkins workspace: $env:WORKSPACE"
                '''
            }
        }
        stage('Build Placeholder') {
            steps {
                powershell 'Write-Host "Build stage complete."'
            }
        }
    }
    post {
        always {
            echo 'Pipeline finished.'
        }
    }
}

Save the job and click Build Now. Open the console output and confirm both stages execute successfully with no errors.

Step 7: Configure Automatic Service Recovery

Configure the Jenkins Windows service to restart automatically on failure:

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

This tells the Service Control Manager to restart Jenkins after a 60-second delay for the first three failures, and to reset the failure count after 24 hours of clean operation.

Step 8: Configure Backup of Jenkins Home

The Jenkins home directory contains all job configurations, build history, credentials, and plugin data. Back it up with a scheduled PowerShell task:

$backupScript = @'
$src = "D:JenkinsHome"
$dst = "\backupserverjenkins$(Get-Date -Format 'yyyyMMdd')"
robocopy $src $dst /MIR /XD workspace /NFL /NDL /NJH
'@

$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NonInteractive -Command `"$backupScript`""
$trigger = New-ScheduledTaskTrigger -Daily -At "02:00AM"
Register-ScheduledTask -TaskName "JenkinsBackup" -Action $action -Trigger $trigger -RunLevel Highest

Note that the workspace subdirectory is excluded from the backup since it can be regenerated from source control and can be very large.

Step 9: Verify Service Status

Get-Service Jenkins | Select-Object Name, Status, StartType
netstat -ano | findstr :8080

The service should show Status: Running and StartType: Automatic. The netstat output should show a LISTENING entry on port 8080 bound to the Jenkins Java process PID.

Troubleshooting

If Jenkins fails to start, check the service wrapper log at C:Program FilesJenkinsjenkins.err.log and the Jenkins log at D:JenkinsHomelogsjenkins.log. Common issues include JAVA_HOME not being set before the service attempts to start (resolve by restarting after setting the environment variable at the machine level) and port 8080 conflicts with other services such as a development Apache Tomcat instance.

Summary

You have installed a fully functional Jenkins CI/CD server on Windows Server 2012 R2. The installation includes Java 17 via Temurin, the Jenkins Windows service with a dedicated service account, a custom home directory on a secondary volume, inbound firewall rules, initial plugin setup, a verified test pipeline confirming PowerShell integration, automatic service recovery, and a scheduled backup job. This foundation supports building full CI/CD pipelines that compile .NET applications with MSBuild, run NUnit or xUnit test suites, and deploy artifacts to IIS or application servers via PowerShell remoting — all integrated within the Jenkins pipeline framework.