tweaks for docker on windows
This commit is contained in:
parent
906a7fccee
commit
451671cd88
4 changed files with 70 additions and 55 deletions
|
@ -1,21 +1,26 @@
|
||||||
# escape=`
|
# escape=`
|
||||||
|
|
||||||
# use windows server core image
|
# use windows server core image
|
||||||
FROM gcr.io/llvm-premerge-checks/agent-windows
|
FROM gcr.io/llvm-premerge-checks/agent-windows
|
||||||
|
|
||||||
# install java
|
# install java
|
||||||
RUN choco install -y openjdk
|
RUN choco install -y openjdk
|
||||||
|
|
||||||
# get Jenkins swarm plugin
|
# get Jenkins swarm plugin
|
||||||
ENV SWARM_PLUGIN_URL="https://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/swarm-client/3.17/swarm-client-3.17.jar"
|
ENV SWARM_PLUGIN_URL="https://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/swarm-client/3.17/swarm-client-3.17.jar"
|
||||||
ENV SWARM_PLUGIN_JAR="C:\jenkins\swarm-client.jar"
|
ENV SWARM_PLUGIN_JAR="C:\jenkins\swarm-client.jar"
|
||||||
RUN powershell -NoProfile -InputFormat None -Command `
|
RUN powershell -NoProfile -InputFormat None -Command `
|
||||||
mkdir c:\jenkins ; `
|
mkdir c:\jenkins ; `
|
||||||
Invoke-WebRequest -Uri %SWARM_PLUGIN_URL% -OutFile %SWARM_PLUGIN_JAR%
|
Invoke-WebRequest -Uri %SWARM_PLUGIN_URL% -OutFile %SWARM_PLUGIN_JAR%
|
||||||
|
|
||||||
# network storage for build results
|
# install gsutils to access Google Cloud Storage
|
||||||
VOLUME C:\results
|
RUN powershell -NoProfile -InputFormat None -Command `
|
||||||
|
(New-Object Net.WebClient).DownloadFile("https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe", "$env:Temp\GoogleCloudSDKInstaller.exe") ; `
|
||||||
# start swarm plugin
|
& $env:Temp\GoogleCloudSDKInstaller.exe ; `
|
||||||
COPY start_agent.bat c:\jenkins
|
del $env:Temp\GoogleCloudSDKInstaller.exe
|
||||||
|
VOLUME C:\credentials
|
||||||
|
VOLUME C:\Temp
|
||||||
|
|
||||||
|
# start swarm plugin
|
||||||
|
COPY start_agent.bat c:\jenkins
|
||||||
CMD c:\jenkins\start_agent.bat
|
CMD c:\jenkins\start_agent.bat
|
|
@ -16,6 +16,11 @@ set JENKINS_SERVER=jenkins.local
|
||||||
|
|
||||||
set AGENT_ROOT=C:\ws
|
set AGENT_ROOT=C:\ws
|
||||||
set WORKSPACE=%AGENT_ROOT%\workspace
|
set WORKSPACE=%AGENT_ROOT%\workspace
|
||||||
if not exist "%WORKSPACE%" mkdir "%WORKSPACE%"
|
|
||||||
|
@rem authenticate gsutil
|
||||||
|
gcloud auth activate-service-account --key-file C:\credentials\build-agent-results_key.json
|
||||||
|
|
||||||
|
set TEMP=C:\TEMP
|
||||||
|
set TMP=%TEMP%
|
||||||
|
|
||||||
java -jar %SWARM_PLUGIN_JAR% -master http://%JENKINS_SERVER%:8080 -executors 1 -fsroot %AGENT_ROOT% -labels windows
|
java -jar %SWARM_PLUGIN_JAR% -master http://%JENKINS_SERVER%:8080 -executors 1 -fsroot %AGENT_ROOT% -labels windows
|
|
@ -1,35 +1,35 @@
|
||||||
# Copyright 2019 Google LLC
|
# Copyright 2019 Google LLC
|
||||||
#
|
#
|
||||||
# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
|
# 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 not use this file except in compliance with the License.
|
||||||
# You may obtain a copy of the License at
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# https://llvm.org/LICENSE.txt
|
# https://llvm.org/LICENSE.txt
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
# define command line arguments
|
# define command line arguments
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory=$true)][string]$IMAGE_NAME,
|
[Parameter(Mandatory=$true)][string]$IMAGE_NAME,
|
||||||
[Parameter(Mandatory=$false)][string]$CMD="",
|
[Parameter(Mandatory=$false)][string]$CMD="",
|
||||||
[string]$token
|
[string]$token
|
||||||
)
|
)
|
||||||
|
|
||||||
# set script to stop on first error
|
# set script to stop on first error
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
# some docs recommend setting 2GB memory limit
|
# some docs recommend setting 2GB memory limit
|
||||||
docker build --memory 2GB -t $IMAGE_NAME --build-arg token=$token "$PSScriptRoot\$IMAGE_NAME"
|
docker build --memory 2GB -t $IMAGE_NAME --build-arg token=$token "$PSScriptRoot\$IMAGE_NAME"
|
||||||
If ($LastExitCode -ne 0) {
|
If ($LastExitCode -ne 0) {
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
# mount a persistent workspace for experiments
|
# mount a persistent workspace for experiments
|
||||||
docker run -it -v D:\:C:\ws $IMAGE_NAME $CMD
|
docker run -it -v D:\:C:\ws -v C:\credentials:C:\credentials $IMAGE_NAME $CMD
|
||||||
If ($LastExitCode -ne 0) {
|
If ($LastExitCode -ne 0) {
|
||||||
exit
|
exit
|
||||||
}
|
}
|
|
@ -19,6 +19,11 @@ $JENKINS_SERVER="jenkins.local"
|
||||||
$AGENT_ROOT="D:\"
|
$AGENT_ROOT="D:\"
|
||||||
$SWARM_PLUGIN_JAR="C:\jenkins\swarm-client.jar"
|
$SWARM_PLUGIN_JAR="C:\jenkins\swarm-client.jar"
|
||||||
|
|
||||||
|
# move temp dir to local SSD
|
||||||
|
mkdir D:\temp
|
||||||
|
$env:temp="D:\temp"
|
||||||
|
$env:tmp=$env:temp
|
||||||
|
|
||||||
java -jar ${SWARM_PLUGIN_JAR} `
|
java -jar ${SWARM_PLUGIN_JAR} `
|
||||||
-master http://${JENKINS_SERVER}:8080 `
|
-master http://${JENKINS_SERVER}:8080 `
|
||||||
-executors 1 `
|
-executors 1 `
|
||||||
|
|
Loading…
Reference in a new issue