Skip to content

Instantly share code, notes, and snippets.

@mefellows
Last active September 12, 2016 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mefellows/6c9faf342817b8412b76 to your computer and use it in GitHub Desktop.
Save mefellows/6c9faf342817b8412b76 to your computer and use it in GitHub Desktop.
TC 2012r2 Build Agent - BoxStarter
# START http://boxstarter.org/package/nr/url?https://gist.githubusercontent.com/mefellows/6c9faf342817b8412b76/raw/953665c62ce975af136cf2e3e8b93beb3a395b9c/boxstarter.ps1
Set-ExplorerOptions -showHidenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Enable-RemoteDesktop
Disable-UAC
Disable-InternetExplorerESC
cinst git.install -y -params '"/GitAndUnixToolsOnPath"'
cinst virtualbox -y
cinst vagrant -y
cinst packer -y
cinst packer-windows-plugins -pre -y
cinst awstools.powershell -y
cinst javaruntime -y
cinst teamcityagent -y -params "serverurl=http://builds.seek.int agentName=$env:COMPUTERNAME agentDir=$env:SystemDrive/buildAgent"
choco install golang -y
choco install hg -y
# Go
$goPath = "${env:SystemDrive}\go"
If ( -not (Test-Path $goPath) ) {
mkdir c:\go
[Environment]::SetEnvironmentVariable("GOPATH", $goPath, "User")
[Environment]::SetEnvironmentVariable("GOPATH", $goPath, "Machine")
$env:path+="${goPath}\bin"
[Environment]::SetEnvironmentVariable("PATH", $env:path, "Machine")
}
# packer s3 upload plugin
go get github.com/lmars/packer-post-processor-vagrant-s3
# Copy binaries into the right place
cp "${env:APPDATA}\packer.d\*" "${env:SystemDrive}\Hashicorp\packer\"
cp "${goPath}\bin\packer-*" "${env:SystemDrive}\Hashicorp\packer\"
# team city environment variables:
Add-Content "${env:SystemDrive}\buildAgent\conf\buildAgent.properties" "`nenv.PACKER_VERSION=0.7.5"
Add-Content "${env:SystemDrive}\buildAgent\conf\buildAgent.properties" "`nenv.PACKER_WINDOWS=1.0.0-RC"
Add-Content "${env:SystemDrive}\buildAgent\conf\buildAgent.properties" "`nenv.PACKER_POST_PROCESSOR_VAGRANT_S3_VERSION=0.0.1" # NOTE: there currently is no version. Consider git hash?
Add-Content "${env:SystemDrive}\buildAgent\conf\buildAgent.properties" "`nenv.VAGRANT_VERSION=1.7"
Add-Content "${env:SystemDrive}\buildAgent\conf\buildAgent.properties" "`nenv.VIRTUALBOX_VERSION=4.3"
cmd.exe /c netsh firewall add portopening TCP 9090 "Port 9090 for TC"
# WinRM
cmd.exe /c winrm quickconfig -q
cmd.exe /c winrm quickconfig '-transport:http'
cmd.exe /c winrm set "winrm/config" '@{MaxTimeoutms="1800000"}'
cmd.exe /c winrm set "winrm/config/winrs" '@{MaxMemoryPerShellMB="1024"}'
cmd.exe /c winrm set "winrm/config/service" '@{AllowUnencrypted="true"}'
cmd.exe /c winrm set "winrm/config/client" '@{AllowUnencrypted="true"}'
cmd.exe /c winrm set "winrm/config/service/auth" '@{Basic="true"}'
cmd.exe /c winrm set "winrm/config/client/auth" '@{Basic="true"}'
cmd.exe /c winrm set "winrm/config/service/auth" '@{CredSSP="true"}'
cmd.exe /c winrm set "winrm/config/listener?Address=*+Transport=HTTP" '@{Port="5985"}'
cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes
cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985"
cmd.exe /c net stop winrm
cmd.exe /c sc config winrm start= auto
cmd.exe /c net start winrm
@dragon788
Copy link

Typo on line 3, I think it's supposed to be Hidden, not Hiden, but this is awesome, I was just looking at how to automate a TeamCity agent with Vagrant to test creating a job DSL library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment