Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows build node SSH connection issue using JCasC #242

Open
robinbanbury opened this issue Feb 25, 2021 · 0 comments · May be fixed by #243
Open

Windows build node SSH connection issue using JCasC #242

robinbanbury opened this issue Feb 25, 2021 · 0 comments · May be fixed by #243

Comments

@robinbanbury
Copy link

When configuring a Windows agent using JCasC, the SSH connection is broken between Jenkins and the agent if 'username/password' authentication is selected.

Windows agent configuration:

- namePrefix: gce-windows-vm
    description: Windows VM running in GCE
    labelString: gce-windows-vm
    template: "https://www.googleapis.com/compute/v1/projects/${projectID}/global/instanceTemplates/jenkins-windows-vm"
    remoteFs: C:\Users\jenkins
    windowsConfiguration:
      passwordCredentialsId: user-pass-credential-id
    retentionTimeMinutesStr: 6
    mode: EXCLUSIVE
    numExecutorsStr: 1
    launchTimeoutSecondsStr: 300
    useInternalAddress: true
    runAsUser: jenkins
    javaExecPath: java
    oneShot: true
    region: "https://www.googleapis.com/compute/v1/projects/${projectID}/regions/${region}"
    zone: "https://www.googleapis.com/compute/v1/projects/${projectID}/zones/${zone}"

The configuration looks suitable when examined in the Jenkins UI, but I can see the following error in the agent logs:

Feb 25, 2021 10:23:16 AM null
WARNING: Failed to authenticate with exception:  Exception: java.lang.NullPointerException

On a closer inspection in the system logs:

Feb 25, 2021 10:44:19 AM WARNING com.google.jenkins.plugins.computeengine.ComputeEngineCloud log
Failed to authenticate with exception: 
java.lang.NullPointerException
	at com.google.jenkins.plugins.computeengine.ComputeEngineWindowsLauncher.authenticateSSH(ComputeEngineWindowsLauncher.java:72)
	at com.google.jenkins.plugins.computeengine.ComputeEngineWindowsLauncher.bootstrap(ComputeEngineWindowsLauncher.java:104)
	at com.google.jenkins.plugins.computeengine.ComputeEngineWindowsLauncher.setupConnection(ComputeEngineWindowsLauncher.java:56)
	at com.google.jenkins.plugins.computeengine.ComputeEngineComputerLauncher.launch(ComputeEngineComputerLauncher.java:301)
	at com.google.jenkins.plugins.computeengine.ComputeEngineComputerLauncher.launch(ComputeEngineComputerLauncher.java:224)
	at hudson.slaves.SlaveComputer.lambda$_connect$0(SlaveComputer.java:296)
	at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
	at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Looking at that line in the code, it seems that windowsConfig.getPrivateKeyCredentialsId() can return a null value, so call isEmpty() on that will cause the NPE.

Workaround is to specify an empty string as the privateKeyCredentialsId, e.g.

  windowsConfiguration:
    privateKeyCredentialsId: ""
    passwordCredentialsId: user-pass-credential-id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant