diff --git a/kubernetes/windows_agent_create.sh b/kubernetes/windows_agent_create.sh index 7717a53..0899915 100755 --- a/kubernetes/windows_agent_create.sh +++ b/kubernetes/windows_agent_create.sh @@ -1,33 +1,33 @@ -#!/bin/bash -# Copyright 2019 Google LLC -# -# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://llvm.org/LICENSE.txt -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eux - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -ROOT_DIR="$(dirname ${DIR})" - -# get config options -# shellcheck source=../k8s_config -source "${ROOT_DIR}/k8s_config" -NAME=agent-windows-2 - -gcloud beta compute instances create "${NAME}" \ - --project="${GCP_PROJECT}" \ - --zone="${GCP_ZONE}" \ - --machine-type=n1-highcpu-32 \ - --local-ssd=device-name=local-ssd-0 \ - --image=windows-server-2019-dc-v20191210 \ - --image-project=windows-cloud \ +#!/bin/bash +# Copyright 2019 Google LLC +# +# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://llvm.org/LICENSE.txt +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eux + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +ROOT_DIR="$(dirname ${DIR})" + +# get config options +# shellcheck source=../k8s_config +source "${ROOT_DIR}/k8s_config" +NAME=agent-windows-2 + +gcloud beta compute instances create "${NAME}" \ + --project="${GCP_PROJECT}" \ + --zone="${GCP_ZONE}" \ + --machine-type=n1-highcpu-32 \ + --local-ssd=device-name=local-ssd-0 \ + --image=windows-server-2019-dc-v20191210 \ + --image-project=windows-cloud \ --boot-disk-size=100GB \ No newline at end of file diff --git a/kubernetes/windows_agent_bootstrap.ps1 b/scripts/windows_agent_bootstrap.ps1 similarity index 93% rename from kubernetes/windows_agent_bootstrap.ps1 rename to scripts/windows_agent_bootstrap.ps1 index 2e379e9..0400f97 100644 --- a/kubernetes/windows_agent_bootstrap.ps1 +++ b/scripts/windows_agent_bootstrap.ps1 @@ -1,33 +1,33 @@ -# Copyright 2019 Google LLC - -# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at - -# https://llvm.org/LICENSE.txt - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -Write-Host "Initializing local SSD..." -New-Variable -Name diskid -Value (Get-Disk -FriendlyName "Google PersistentDisk").Number -# TODO: check if machine has an SSD -# TODO: only do this, if SSD is not yet usable -Initialize-Disk -Number $diskid -New-Partition -DiskNumber $diskid -UseMaximumSize -AssignDriveLetter -Format-Volume -DriveLetter D - -Write-Host "install chocolately as package manager..." -iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) -choco feature disable --name showDownloadProgress -choco install git - -Write-Host "Mounting result storage..." -Install-WindowsFeature NFS-Client -net use E: \\results.local\exports - -Set-Location D:\ -git clone https://github.com/google/llvm-premerge-checks +# Copyright 2019 Google LLC + +# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# https://llvm.org/LICENSE.txt + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +Write-Host "Initializing local SSD..." +New-Variable -Name diskid -Value (Get-Disk -FriendlyName "Google PersistentDisk").Number +# TODO: check if machine has an SSD +# TODO: only do this, if SSD is not yet usable +Initialize-Disk -Number $diskid +New-Partition -DiskNumber $diskid -UseMaximumSize -AssignDriveLetter +Format-Volume -DriveLetter D + +Write-Host "install chocolately as package manager..." +iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) +choco feature disable --name showDownloadProgress +choco install git + +Write-Host "Mounting result storage..." +Install-WindowsFeature NFS-Client +net use E: \\results.local\exports /PERSISTENT:YES + +Set-Location D:\ +git clone https://github.com/google/llvm-premerge-checks diff --git a/kubernetes/windows_agent_install.ps1 b/scripts/windows_agent_install.ps1 similarity index 73% rename from kubernetes/windows_agent_install.ps1 rename to scripts/windows_agent_install.ps1 index 5078004..dc0f848 100644 --- a/kubernetes/windows_agent_install.ps1 +++ b/scripts/windows_agent_install.ps1 @@ -1,47 +1,48 @@ -# Copyright 2019 Google LLC - -# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at - -# https://llvm.org/LICENSE.txt - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -Write-Host "Installing Visual Studio build tools..." -choco install visualcpp-build-tools --version 15.0.26228.20170424 -y --params "'/IncludeOptional'" -Write-Host 'Waiting for Visual C++ Build Tools to finish' -Wait-Process -Name vs_installer - -Write-Host "Installing misc tools" -# install other tools as described in https://llvm.org/docs/GettingStartedVS.html -# and a few more that were not documented... -choco install -y git python2 ninja gnuwin cmake -pip install psutil - -Write-Host "Setting environment variables..." -$Env:PYTHONIOENCODING=UTF-8 -$Env:path = $Env:path + ';c:\Program Files (x86)\GnuWin32\bin;C:\Program Files\CMake\bin' - -# support long file names during git checkout -Write-Host "Setting git config..." -git config --system core.longpaths true -git config --global core.autocrlf false - -# Above: genric LLVM-related things -#------------- -# Below: Jenkins specific things - -Write-Host "Installing openjdk..." -choco install -y openjdk - -Write-Host "Installing Jenkins swarm agent..." -$SWARM_PLUGIN_URL="https://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/swarm-client/3.17/swarm-client-3.17.jar" -$SWARM_PLUGIN_JAR="C:\jenkins\swarm-client.jar" -mkdir c:\jenkins -Invoke-WebRequest -Uri $SWARM_PLUGIN_URL -OutFile $SWARM_PLUGIN_JAR +# Copyright 2019 Google LLC + +# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# https://llvm.org/LICENSE.txt + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +. ${PSScriptRoot}\common.ps1 + +Write-Host "Installing Visual Studio build tools..." +choco install -y visualcpp-build-tools --version 15.0.26228.20170424 -y --params "'/IncludeOptional'" +Write-Host 'Waiting for Visual C++ Build Tools to finish' +Wait-Process -Name vs_installer + +Write-Host "Installing misc tools" +# install other tools as described in https://llvm.org/docs/GettingStartedVS.html +# and a few more that were not documented... +choco install -y git python2 ninja gnuwin cmake +pip install psutil + +Write-Host "Setting environment variables..." +[System.Environment]::SetEnvironmentVariable('PYTHONIOENCODING', 'UTF-8', [System.EnvironmentVariableTarget]::User) +$oldpath=[System.Environment]::GetEnvironmentVariable('path',[System.EnvironmentVariableTarget]::User) +[System.Environment]::SetEnvironmentVariable('path', $oldpath + 'c:\Program Files (x86)\GnuWin32\bin;C:\Program Files\CMake\bin', [System.EnvironmentVariableTarget]::User) +# support long file names during git checkout +Write-Host "Setting git config..." +git config --system core.longpaths true +git config --global core.autocrlf false + +# Above: genric LLVM-related things +#------------- +# Below: Jenkins specific things + +Write-Host "Installing openjdk..." +choco install -y openjdk + +Write-Host "Installing Jenkins swarm agent..." +$SWARM_PLUGIN_URL="https://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/swarm-client/3.17/swarm-client-3.17.jar" +$SWARM_PLUGIN_JAR="C:\jenkins\swarm-client.jar" +mkdir c:\jenkins +Invoke-WebRequest -Uri $SWARM_PLUGIN_URL -OutFile $SWARM_PLUGIN_JAR diff --git a/scripts/windows_agent_start.ps1 b/scripts/windows_agent_start.ps1 new file mode 100644 index 0000000..48b9ec9 --- /dev/null +++ b/scripts/windows_agent_start.ps1 @@ -0,0 +1,22 @@ +# Copyright 2019 Google LLC +# +# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://llvm.org/LICENSE.txt +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +. ${PSScriptRoot}\common.ps1 + +$JENKINS_SERVER="jenkins.local" +$AGENT_ROOT="D:\" +$SWARM_PLUGIN_JAR="C:\jenkins\swarm-client.jar" + +java -jar ${SWARM_PLUGIN_JAR} -master http://${JENKINS_SERVER}:8080 -executors 1 -fsroot ${AGENT_ROOT} -labels windows \ No newline at end of file