github.com/secure-build/gitlab-runner@v12.5.0+incompatible/scripts/vagrant/provision/base.ps1 (about)

     1  $goVersion = "1.10"
     2  $gitVersion = "2.23.0"
     3  $srcFolder = "C:\Go\src\gitlab.com\gitlab-org\gitlab-runner"
     4  
     5  function Main
     6  {
     7      [environment]::SetEnvironmentVariable("RUNNER_SRC", $srcFolder, "Machine")
     8      Install-Go($goVersion)
     9      Install-Git($gitVersion)
    10  }
    11  
    12  function Install-Go([string]$version)
    13  {
    14      $file = 'go' + $version +'.windows-amd64.msi'
    15      $url = 'https://storage.googleapis.com/golang/' + $file
    16      $dest = Download -Url $url
    17  
    18  
    19      Write-Host "installing go $version..."
    20      $logFile = Log-File -App 'go'
    21      $MSIArguments = @(
    22          "/i"
    23          ('"{0}"' -f $dest)
    24          "/qn"
    25          "/norestart"
    26          "/L*v"
    27          $logFile
    28      )
    29      Start-Process "msiexec.exe" -ArgumentList $MSIArguments -Wait -NoNewWindow
    30  
    31      Write-Host "done"
    32      Remove-Item $dest
    33  }
    34  
    35  function Install-Git([string]$version)
    36  {
    37      $releaseVersion = 'v' + $version + '.windows.1'
    38      $file = 'Git-' + $version +'-64-bit.exe'
    39      $url = GitHubRelease -Project 'git-for-windows/git' -Version $releaseVersion -File $file
    40      $dest = Download -Url $url
    41  
    42      Write-Host "installing git $version..."
    43      $logFile = Log-File -App 'git'
    44      $InstallArguments = @(
    45          "/VERYSILENT"
    46          ('/LOG="{0}"' -f $logFile)
    47      )
    48      Start-Process $dest -ArgumentList $InstallArguments -Wait -NoNewWindow
    49  
    50      Write-Host "done"
    51      Remove-Item $dest
    52  }
    53  
    54  function GitHubRelease([string]$Project, [string]$Version = 'latest', [string]$File) {
    55      'https://github.com/' + $Project + '/releases/download/' + $Version + '/' + $File
    56  }
    57  
    58  function Download([string]$Url) {
    59      $dest = [System.IO.Path]::GetTempFileName()
    60      [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11"
    61      Write-Host "downloading $Url"
    62  
    63      # Create client, set its info, and download
    64      $wc = New-Object System.Net.WebClient
    65      $wc.UseDefaultCredentials = $true
    66      $wc.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")
    67      $wc.DownloadFile($Url, $dest)
    68  
    69      Write-Host "$url downloaded as $dest"
    70      $dest
    71  }
    72  
    73  function Log-File($App)
    74  {
    75      $timestamp = get-date -Format yyyyMMddTHHmmss
    76      $logFile = '{0}-{1}.log' -f $App,$timestamp
    77      $vagrantFolder = Join-Path -Path $srcFolder -ChildPath ".vagrant"
    78      Join-Path -Path $vagrantFolder -ChildPath $logFile
    79  }
    80  
    81  Main