Skip to content

Provisioning the windows machine for running jasmine karma tests

marques-work edited this page Jul 10, 2020 · 10 revisions

Provisioning the windows machine for running jasmine/karma tests

1. Provision a VM instance

Use Windows 10 (and not Server 2019 Datacenter); MS Edge (EdgeHTML/Chakra) only runs on Windows 10. Haven't looked at install Chromium-based Edge.

The standard VM size and such will work just fine. Resource group: build-gocd, region: East US.

Set the following user creds:

  • User: go
  • Password: <See 1Password for the password>

Update 1Password with the new public IP address of the VM so folks can connect to it as necessary.

2. Install Chocolatey

Run this in a PowerShell session as the administrator:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

3. Packages

Restart your PowerShell administrative session to ensure choco is on your PATH

choco install -y git --params "/GitAndUnixToolsOnPath /NoAutoCrlf"

# JDK 11, because Gradle 5 can't use JDK 13+
choco install -y nodejs yarn ruby openjdk11 selenium-gecko-driver firefox

4. Install the GoCD Agent

Download the Windows agent from the downloads page.

Run the installer in an administrative command prompt:

go-agent-${version}-setup.exe /S /START_AGENT=NO /SERVERURL="https://build.gocd.org/go" /D=C:\go

Disable the GoCD Agent service (the service will start up the agent as the SYSTEM user, which is very problematic).

Set-Service "Go Agent" -StartupType Disabled

Create a shortcut to launch the agent on startup. This can be done in one of two ways:

  1. Manually: Open the startup folder by running (i.e., Win+R) shell:startup and manually creating a shortcut to C:\go\bin\go-agent.bat.

  2. Command line: In the PowerShell session:

    $WshShell = New-Object -ComObject WScript.Shell
    $objShortCut = $WshShell.CreateShortcut($env:USERPROFILE + "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" + "\go-agent.lnk")
    $objShortCut.TargetPath = "C:\go\bin\go-agent.bat"
    $objShortCut.Save()

Run the go-agent script to start the agent process in the current session

Just run (Win+R): C:\go\bin\go-agent.bat.

5. Relax Security Policies to Allow Builds to Succeed

Allow PowerShell scripts to execute

# karma-edge-launcher (maybe others too) needs to run PowerShell scripts
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine

Exclude the agent directory from Windows defender to prevent constant scanning during builds. Alternatively, disable defender entirely: Set-MpPreference -DisableRealtimeMonitoring $true.

Add-MpPreference -ExclusionPath "C:\go"

Alternatively, you can just disable defender altogether:

Set-MpPreference -DisableRealtimeMonitoring $true

NOTE: During the first job run, you may get a Windows Defender prompt to allow inbound port access from Java and/or Node. Allow this.