From 6a8f7c625f9d8120b62cefbb1bee2470481976b4 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Wed, 2 Nov 2022 14:49:06 -0400 Subject: [PATCH] Add JENKINS_HOME_PATH as default JENKINS_HOME always returns /var/jenkins_home (#215) * Add JENKINS_HOME_PATH as default JENKINS_HOME always returns /var/jenkins_home Signed-off-by: Peter Zhu * Tweak JDK 14 to support windows installation Signed-off-by: Peter Zhu Signed-off-by: Peter Zhu --- lib/compute/agent-node-config.ts | 36 ++++++++++++++++++++++++++++ resources/baseJenkins.yaml | 12 ++++++++-- test/data/test_env.yaml | 40 +++++++++++++++++++++++++++++--- 3 files changed, 83 insertions(+), 5 deletions(-) diff --git a/lib/compute/agent-node-config.ts b/lib/compute/agent-node-config.ts index 5845fd6..a322221 100644 --- a/lib/compute/agent-node-config.ts +++ b/lib/compute/agent-node-config.ts @@ -196,6 +196,18 @@ export class AgentNodeConfig { ], tenancy: 'Default', type: config.instanceType, + nodeProperties: [ + { + envVars: { + env: [ + { + key: 'JENKINS_HOME_PATH', + value: config.remoteFs, + }, + ], + }, + }, + ], useEphemeralDevices: false, }; } @@ -243,6 +255,18 @@ export class AgentNodeConfig { ], tenancy: 'Host', type: config.instanceType, + nodeProperties: [ + { + envVars: { + env: [ + { + key: 'JENKINS_HOME_PATH', + value: config.remoteFs, + }, + ], + }, + }, + ], useEphemeralDevices: false, }; } @@ -293,6 +317,18 @@ export class AgentNodeConfig { ], tenancy: 'Default', type: config.instanceType, + nodeProperties: [ + { + envVars: { + env: [ + { + key: 'JENKINS_HOME_PATH', + value: config.remoteFs, + }, + ], + }, + }, + ], useEphemeralDevices: false, }; } diff --git a/resources/baseJenkins.yaml b/resources/baseJenkins.yaml index 1c0a0fb..fca089d 100644 --- a/resources/baseJenkins.yaml +++ b/resources/baseJenkins.yaml @@ -175,8 +175,16 @@ tool: properties: - installSource: installers: - - zip: - url: "https://ci.opensearch.org/ci/dbc/tools/OpenJDK14U-jdk_x64_linux_hotspot_14.0.2_12.zip" + - command: + command: "JENKINS_HOME_LINUX=\"/var/jenkins\"\nJENKINS_HOME_WINDOWS=\"\ + C:/Users/Administrator/jenkins\"\n \n\nif uname -s | grep -i NT; then\n\ + \ echo windows agent\n JENKINS_JDK14_PATH=$JENKINS_HOME_WINDOWS/tools/hudson.model.JDK/openjdk-14\n\ + \ JDK14_ZIP=\"OpenJDK14U-jdk_x64_windows_hotspot_14.0.2_12.zip\"\ + \n \nelse\n echo linux agent\n JENKINS_JDK14_PATH=$JENKINS_HOME_LINUX/tools/hudson.model.JDK/openjdk-14\n\ + \ JDK14_ZIP=\"OpenJDK14U-jdk_x64_linux_hotspot_14.0.2_12.zip\"\ + \n \nfi\n\n\nmkdir -p $JENKINS_JDK14_PATH\ncd $JENKINS_JDK14_PATH\n\ + pwd\nrm -rf ./*\ncurl -sSL https://ci.opensearch.org/ci/dbc/tools/$JDK14_ZIP\ + \ -o jdk14.zip\nunzip -q jdk14.zip\nrm jdk14.zip\n\n" - name: "openjdk-17" properties: - installSource: diff --git a/test/data/test_env.yaml b/test/data/test_env.yaml index 266c6f5..ae21bed 100644 --- a/test/data/test_env.yaml +++ b/test/data/test_env.yaml @@ -187,9 +187,43 @@ tool: properties: - installSource: installers: - - zip: - url: >- - https://ci.opensearch.org/ci/dbc/tools/OpenJDK14U-jdk_x64_linux_hotspot_14.0.2_12.zip + - command: + command: >+ + JENKINS_HOME_LINUX="/var/jenkins" + + JENKINS_HOME_WINDOWS="C:/Users/Administrator/jenkins" + + + if uname -s | grep -i NT; then + echo windows agent + JENKINS_JDK14_PATH=$JENKINS_HOME_WINDOWS/tools/hudson.model.JDK/openjdk-14 + JDK14_ZIP="OpenJDK14U-jdk_x64_windows_hotspot_14.0.2_12.zip" + + else + echo linux agent + JENKINS_JDK14_PATH=$JENKINS_HOME_LINUX/tools/hudson.model.JDK/openjdk-14 + JDK14_ZIP="OpenJDK14U-jdk_x64_linux_hotspot_14.0.2_12.zip" + + fi + + + + mkdir -p $JENKINS_JDK14_PATH + + cd $JENKINS_JDK14_PATH + + pwd + + rm -rf ./* + + curl -sSL + https://ci.opensearch.org/ci/dbc/tools/$JDK14_ZIP -o + jdk14.zip + + unzip -q jdk14.zip + + rm jdk14.zip + - name: openjdk-17 properties: - installSource: