Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create a Jenkins Master on a Windows Server 2012 R2 Core install
# Configure the settings to use to setup this Jenkins Executor
$Port = 80
$IPAddress = '192.168.1.96'
$SubnetPrefixLength = 24
$DNSServers = @('192.168.1.1')
$DefaultGateway = '192.168.1.1'
# Install .NET Framework 3.5
Install-WindowsFeature -Name NET-Framework-Core
# Install Chocolatey
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
# Install JDK 8
choco install jdk8 -y
# Install Jenkins using Chocolatey
choco install Jenkins -y
# Set the port Jenkins uses
$Config = Get-Content `
-Path "${ENV:ProgramFiles(x86)}\Jenkins\Jenkins.xml"
$NewConfig = $Config `
-replace '--httpPort=[0-9]*\s',"--httpPort=$Port "
Set-Content `
-Path "${ENV:ProgramFiles(x86)}\Jenkins\Jenkins.xml" `
-Value $NewConfig `
-Force
Restart-Service `
-Name Jenkins
# Set a static IP Address - optional
New-NetIPAddress `
-IPAddress $IPAddress `
-InterfaceAlias Ethernet `
-DefaultGateway $DefaultGateway `
-AddressFamily IPv4 `
-PrefixLength $SubnetPrefixLength
Set-DnsClientServerAddress `
-InterfaceAlias Ethernet `
-Addresses $DNSServers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment