Search code examples
jenkinsjenkins-agent

I added a Jenkins agent running on windows Windows - it won't start


I have a Jenkins controller running on Linux and I want to add a Windows agent. Currently I am not able to start the agent:

  1. Java Web Start

-> Java Web Start is removed in JDK 11 (and was never part of OpenJDK), so as we want to switch our Jenkins to run with openjdk11, this won't work anymore, so I did not even try this.

  1. Windows Slave Plugin

-> I followed the Troubleshootings and made sure ports 135, 139 and 445 are reachable from my Jenkins master. Sadly, I still receive an error:

2019-06-12 14:54:28] [windows-slaves] Connecting to 1.2.3.4
ERROR: Message not found for errorCode: 0xC0000001
org.jinterop.dcom.common.JIException: Message not found for errorCode: 0xC0000001
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKCR(JIWinRegStub.java:121)
    at org.jinterop.dcom.core.JIComServer.initialise(JIComServer.java:479)
    at org.jinterop.dcom.core.JIComServer.<init>(JIComServer.java:427)
    at org.jvnet.hudson.wmi.WMI.connect(WMI.java:59)
    at hudson.os.windows.ManagedWindowsServiceLauncher.launch(ManagedWindowsServiceLauncher.java:208)
    at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:294)
    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)
Caused by: jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/1.2.3.4
jcifs.util.transport.TransportException
java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:210)
    at java.net.SocketInputStream.read(SocketInputStream.java:141)
    at jcifs.util.transport.Transport.readn(Transport.java:29)
    at jcifs.smb.SmbTransport.peekKey(SmbTransport.java:388)
    at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:288)
    at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
    at jcifs.util.transport.Transport.run(Transport.java:241)
    at java.lang.Thread.run(Thread.java:748)

    at jcifs.util.transport.Transport.run(Transport.java:258)
    at java.lang.Thread.run(Thread.java:748)

    at jcifs.smb.SmbTransport.connect(SmbTransport.java:309)
    at jcifs.smb.SmbTree.treeConnect(SmbTree.java:156)
    at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
    at jcifs.smb.SmbFile.connect(SmbFile.java:954)
    at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
    at jcifs.smb.SmbFileInputStream.<init>(SmbFileInputStream.java:77)
    at jcifs.smb.SmbFileInputStream.<init>(SmbFileInputStream.java:66)
    at jcifs.smb.SmbFile.getInputStream(SmbFile.java:2844)
    at rpc.ncacn_np.RpcTransport.attach(RpcTransport.java:90)
    at rpc.Stub.attach(Stub.java:104)
    at rpc.Stub.call(Stub.java:109)
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKCR(JIWinRegStub.java:119)
    ... 11 more

Does anyone have a suggestion? Or an alternative to the two mentioned approaches?


Edit:

I have to mention that the controller is running on-prem and the agent is an Azure VM. There is an ExpressRoute and, as I said, ports (135, 139, 445) are open (telnet from controller to agent was successful for these ports).


Solution

  • I gave up with the Windows Slave Plugin. Instead, I successfully connected to the slave via SSH!

    SSH Daemon is not installed by default on my Windows 2019 Server, so I had to run these commands:

    # install openSSH server
    Add-WindowsCapability -Online -Name $(Get-WindowsCapability -Online | ? Name -like 'OpenSSH.Server*' | Select -ExpandProperty Name)
    
    # start sshd
    Start-Service sshd
    
    # enable sshd as a service
    Set-Service -Name sshd -StartupType 'Automatic'
    
    # check if firewall rule was automatically created
    Get-NetFirewallRule -Name *ssh*
    

    Hint: Java >= 8 has to be installed (and added to PATH) on the Slave.