jenkinsci / jenkinsci/google-compute-engine-plugin

Nullsafe operator required

Open
#445 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
58
Forks
97
PR merge metrics
No merged PRs in 30d

Description

I'm using windows agents with password auth. And it does not work if I use JCasC. Because privateKeyCredentialsId is empty for an instance configuration in the exported yaml file.

And that's why I got NPE:
```
2024-02-26 17:19:11.011+0000 [id=787] WARNING c.g.j.p.c.ComputeEngineCloud#log: Failed to authenticate with exception:
java.lang.NullPointerException
at com.google.jenkins.plugins.computeengine.ComputeEngineWindowsLauncher.authenticateSSH(ComputeEngineWindowsLauncher.java:66)
at com.google.jenkins.plugins.computeengine.ComputeEngineWindowsLauncher.bootstrap(ComputeEngineWindowsLauncher.java:95)
```

So in that line:
https://github.com/jenkinsci/google-compute-engine-plugin/blob/5ed247be6b4264cbc33f7d2a4cabf399fb59b75d/src/main/java/com/google/jenkins/plugins/computeengine/ComputeEngineWindowsLauncher.java#L66C13-L66C66

it should be like this: `getPrivateKeyCredentialsId()?.isEmpty()`

Workaround: add to your yaml `privateKeyCredentialsId: ""` even if you need to use only `passwordCredentialsId`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.