From a5103d2891a2c5136dc74c91eddd67d65f5c4438 Mon Sep 17 00:00:00 2001 From: Karol Lassak Date: Tue, 13 Jul 2021 12:26:07 +0200 Subject: [PATCH 1/2] Fix NPE when private key is not set --- .../plugins/computeengine/ComputeEngineWindowsLauncher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/google/jenkins/plugins/computeengine/ComputeEngineWindowsLauncher.java b/src/main/java/com/google/jenkins/plugins/computeengine/ComputeEngineWindowsLauncher.java index 6862067f..f243233e 100644 --- a/src/main/java/com/google/jenkins/plugins/computeengine/ComputeEngineWindowsLauncher.java +++ b/src/main/java/com/google/jenkins/plugins/computeengine/ComputeEngineWindowsLauncher.java @@ -69,7 +69,7 @@ public static boolean authenticateSSH( TaskListener listener) throws Exception { boolean isAuthenticated; - if (!windowsConfig.getPrivateKeyCredentialsId().isEmpty()) { + if (!Strings.isNullOrEmpty(windowsConfig.getPrivateKeyCredentialsId())) { isAuthenticated = SSHAuthenticator.newInstance( sshConnection, windowsConfig.getPrivateKeyCredentials(), windowsUsername) From eb63563a6eeec48365216cdff526e186ceed7439 Mon Sep 17 00:00:00 2001 From: Karol Lassak Date: Thu, 15 Jul 2021 12:54:30 +0200 Subject: [PATCH 2/2] Add missing import --- .../plugins/computeengine/ComputeEngineWindowsLauncher.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/google/jenkins/plugins/computeengine/ComputeEngineWindowsLauncher.java b/src/main/java/com/google/jenkins/plugins/computeengine/ComputeEngineWindowsLauncher.java index f243233e..4f94498d 100644 --- a/src/main/java/com/google/jenkins/plugins/computeengine/ComputeEngineWindowsLauncher.java +++ b/src/main/java/com/google/jenkins/plugins/computeengine/ComputeEngineWindowsLauncher.java @@ -18,6 +18,7 @@ import com.google.api.services.compute.model.Operation; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; +import com.google.common.base.Strings; import com.trilead.ssh2.Connection; import hudson.model.TaskListener; import java.io.IOException;