jenkinsci / google-compute-engine-plugin

https://plugins.jenkins.io/google-compute-engine/
Apache License 2.0
55 stars 84 forks source link

Nullsafe operator required #445

Open ilmenshik opened 4 months ago

ilmenshik commented 4 months ago

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