You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

setup.ps1 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. $ErrorActionPreference = 'Stop'
  2. function Install-Chocolatey {
  3. # Run the installer.
  4. Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
  5. }
  6. function Install-NodeJs {
  7. choco install -y nodejs
  8. }
  9. function Install-Buildtools {
  10. $path = "${env:Temp}\buildTools.zip"
  11. # Fetch the build tools archive.
  12. [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  13. (New-Object System.Net.WebClient).DownloadFile('https://github.com/SonarSource/buildTools/archive/docker.zip', $path)
  14. # Extract the archive to the C drive.
  15. Add-Type -AssemblyName System.IO.Compression.FileSystem
  16. [System.IO.Compression.ZipFile]::ExtractToDirectory($path, 'C:\')
  17. # Update global PATH.
  18. $currentPath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).Path
  19. $updatedPath = $currentPath+';C:\buildTools-docker\bin'
  20. Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $updatedPath
  21. # Remove archive.
  22. del $path
  23. }
  24. function Install-Maven {
  25. choco install -y openjdk11 --version 11.0.4.11
  26. choco install -y maven --version 3.6.2
  27. }
  28. function Install-Git {
  29. # We use Git to enable Unix Tools. This will allow us to use Bash-style
  30. # commands in .cirrus.yml, like "source".
  31. choco install -y git --version 2.23.0 --package-parameters "/GitAndUnixToolsOnPath"
  32. }
  33. Write-Host "Install chocolatey"
  34. Install-Chocolatey
  35. Write-Host "Install Maven"
  36. Install-Maven
  37. Write-Host "Install NodeJs"
  38. Install-NodeJs
  39. Write-Host "Install Unix Tools"
  40. Install-Git
  41. Write-Host "Set up build tools"
  42. Install-Buildtools
  43. # Disable antivirus analysis on C drive.
  44. Write-Host "Finalize VM configuration"
  45. Set-MpPreference -ScanAvgCPULoadFactor 5 -ExclusionPath "C:\"