Merge "add infra key to job"
[infra/cicd.git] / jjb / geode-native-win / apache-geode-native-win-slave / slave-win-setup.ps1
1 # ============LICENSE_START=======================================================
2 #  Copyright (C) 2018-2020 Nordix Foundation.
3 # ================================================================================
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 # SPDX-License-Identifier: Apache-2.0
17 # ============LICENSE_END=========================================================
18
19 # Wrapper function for choco (Software management automation for Windows)
20 function Install-Choco {
21     [CmdletBinding()]
22     param(
23         [Parameter(Mandatory)]
24         [string] $PackageName,
25         [string[]] $ArgumentList
26     )
27
28     process {
29         $count = 1
30         while($true)
31         {
32             Write-Host "Running [#$count]: choco install $packageName -y $ArgumentList"
33             choco install $packageName -y @ArgumentList
34
35             $pkg = choco list --localonly $packageName --exact --all --limitoutput
36             if ($pkg) {
37                 Write-Host "Package installed: $pkg"
38                 break
39             }
40             else {
41                 $count++
42                 if ($count -ge 5) {
43                     Write-Host "Could not install $packageName after $count attempts"
44                     exit 1
45                 }
46                 Start-Sleep -Seconds 30
47             }
48         }
49     }
50 }
51
52 # Get required version of geode server to execute geode-native (client) tests
53 function Get-GeodeServer {
54     [CmdletBinding()]
55     param(
56         [Parameter(Mandatory)]
57         [string] $GeodeVersion,
58         [Parameter(Mandatory)]
59         [string] $LocationPath
60     )
61     process {
62         $GeodeURL = "https://downloads.apache.org/geode/" + $GeodeVersion + "/apache-geode-" + $GeodeVersion + ".tgz"
63         $GeodePackage = "apache-geode-" + $GeodeVersion + ".tgz"
64         Write-Host "`nDownloading Geode Server version: $GeodeVersion"
65         Write-Host "from URL: $GeodeURL `n"
66         wget -Verbose $GeodeURL -OutFile $GeodePackage
67         If(!(test-path $LocationPath))
68         {
69             New-Item -ItemType Directory -Force -Path $LocationPath
70         }
71         Write-Host "`nExtracting Geode Server to: ${LocationPath}apache-geode-${GeodeVersion} `n"
72         tar -xzvf $GeodePackage -C $LocationPath
73         $env:GEODE_HOME = $LocationPath + "\apache-geode-" + $GeodeVersion
74     }
75 }
76
77 Write-Host "Install Git, version: latest"
78 Install-Choco -PackageName git.install
79
80 Write-Host "Install Doxygen, version: latest"
81 Install-Choco -PackageName doxygen.install
82
83 Write-Host "Install NUnit, version: ${ENV:NUNIT_VERSION}"
84 Install-Choco -PackageName nunit.install -ArgumentList "--version",${ENV:NUNIT_VERSION},"--allow-downgrade"
85
86 Write-Host "Install OpenSSL, version: latest"
87 Install-Choco -PackageName openssl
88
89 Write-Host "Install CMake, version: latest"
90 Install-Choco -PackageName cmake.portable
91
92 Write-Host "Install Dogtail, version: ${ENV:DOTNET_VERSION}"
93 Install-Choco -PackageName dotnet${ENV:DOTNET_VERSION}
94
95 Write-Host "Install .NET Framework and DevPack, version: ${ENV:DEV_DOTNET_VERSION}"
96 Install-Choco -PackageName "dotnet${ENV:DEV_DOTNET_VERSION}"
97 Install-Choco -PackageName "netfx-${ENV:DEV_DOTNET_VERSION}-devpack" -ArgumentList "--allowEmptyChecksums","-confirm"
98
99 Write-Host "Install GNU Win32 Core utilities, version: latest"
100 Install-Choco -PackageName gnuwin32-coreutils.portable
101
102 Write-Host "Install NSIS, version: latest"
103 Install-Choco -PackageName nsis
104
105 Write-Host "Install patch, version: latest"
106 Install-Choco -PackageName patch
107
108 Write-Host "Install NuGet, version: latest"
109 Install-Choco -PackageName nuget.commandline
110
111 Get-GeodeServer -GeodeVersion ${ENV:GEODE_SERVER_VERSION} -LocationPath ${ENV:GEODE_SERVER_PATH}