Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-57126

Support alternative drive letters for Windows ssh agents using PowerShell/Win32-OpenSSH

    Details

    • Type: Improvement
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Duplicate
    • Component/s: ssh-slaves-plugin
    • Labels:
      None
    • Environment:
    • Similar Issues:

      Description

      I was able to successfully connect the Windows machine with PowerShell/Win32-OpenSSH using the "SSH Slaves plugin" using the "Remote root directory" of "C:\jenkins-agent", and I'm able to run Windows builds on this agent.

      The issue occurs when I change the "Remote root directory" to "D:\jenkins-agent", then the agent fails to launch:

      [04/20/19 09:21:28] [SSH] Remote file system root D:\jenkins-agent does not exist. Will try to create it...

      [04/20/19 09:21:28] [SSH] Copying latest remoting.jar...

      [04/20/19 09:21:29] [SSH] Copied 789,283 bytes.
      Expanded the channel window size to 4MB
      [04/20/19 09:21:29] [SSH] Starting agent process: cd "D:\jenkins-agent" && "C:\Program Files (x86)\Java\jre1.8.0_201\bin\java.exe" -jar remoting.jar -workDir D:\jenkins-agent
      Error: Unable to access jarfile remoting.jar
      Slave JVM has terminated. Exit code=1
      [04/20/19 09:21:29] Launch failed - cleaning up connection
      [04/20/19 09:21:29] [SSH] Connection closed.

      The root cause appears to be that the command 'cd "D:\jenkins-agent"' does not successfully change to the D:\ drive, because when using Windows command prompt, you need to add the '/d' argument to the 'cd' command to change the drive:

      /d : Changes the current drive or the current directory for a drive.

        Attachments

          Issue Links

            Activity

            Hide
            rkivisto Ray Kivisto added a comment -

            I am able to work around this error by adding a "Prefix Start Agent Command" of:

            cd /d D:\ &&

            Then the agent will connect successfully, and I'm able to run Windows builds on this agent.

            Show
            rkivisto Ray Kivisto added a comment - I am able to work around this error by adding a "Prefix Start Agent Command" of: cd /d D:\ && Then the agent will connect successfully, and I'm able to run Windows builds on this agent.
            Hide
            jansohn Robin Jansohn added a comment -

            +1. Just what I wanted to propose, too! But I'm not sure if it's that easy as the /d switch does not exist on *nix systems as far as I know...

            Show
            jansohn Robin Jansohn added a comment - +1. Just what I wanted to propose, too! But I'm not sure if it's that easy as the /d switch does not exist on *nix systems as far as I know...
            Hide
            rkivisto Ray Kivisto added a comment -

            I have some WIP for my idea how to implement this at https://github.com/jenkinsci/ssh-slaves-plugin/compare/master...rkivisto:alternative-windows-drives

            I still need to do additional testing to ensure I don't regress other platforms, and ensure I don't break Windows agents that use the Cygwin installed OpenSSH.

             

            Show
            rkivisto Ray Kivisto added a comment - I have some WIP for my idea how to implement this at https://github.com/jenkinsci/ssh-slaves-plugin/compare/master...rkivisto:alternative-windows-drives I still need to do additional testing to ensure I don't regress other platforms, and ensure I don't break Windows agents that use the Cygwin installed OpenSSH.  
            Hide
            rkivisto Ray Kivisto added a comment - - edited

            I tested my WIP at

               https://github.com/jenkinsci/ssh-slaves-plugin/compare/master...rkivisto:alternative-windows-drives

            using Cygwin by following the instructions at:

               https://go.cloudbees.com/docs/cloudbees-core/cloud-admin-guide/agents/#_microsoft_windows

            I found that my WIP still needs to take into account when the build agent is using Cygwin OpenSSH, because right now it is passing the "/d" argument to "cd" from Cygwin, and it fails with the message:

              "bash: line 0: cd: too many arguments"

             

            I see that there is the environment variable "OSTYPE=cygwin" that is available, so I could check if we are using cygwin.

            Show
            rkivisto Ray Kivisto added a comment - - edited I tested my WIP at    https://github.com/jenkinsci/ssh-slaves-plugin/compare/master...rkivisto:alternative-windows-drives using Cygwin by following the instructions at:    https://go.cloudbees.com/docs/cloudbees-core/cloud-admin-guide/agents/#_microsoft_windows I found that my WIP still needs to take into account when the build agent is using Cygwin OpenSSH, because right now it is passing the "/d" argument to "cd" from Cygwin, and it fails with the message:   "bash: line 0: cd: too many arguments"   I see that there is the environment variable "OSTYPE=cygwin" that is available, so I could check if we are using cygwin.
            Hide
            rkivisto Ray Kivisto added a comment -

            I've implemented cygwin detection, and re-tested the feature.

            It's working for me locally and I've submitted a PR:

            https://github.com/jenkinsci/ssh-slaves-plugin/pull/134

            Show
            rkivisto Ray Kivisto added a comment - I've implemented cygwin detection, and re-tested the feature. It's working for me locally and I've submitted a PR: https://github.com/jenkinsci/ssh-slaves-plugin/pull/134
            Show
            rkivisto Ray Kivisto added a comment - Closing, as per  https://github.com/jenkinsci/ssh-slaves-plugin/pull/134#issuecomment-513543680

              People

              • Assignee:
                rkivisto Ray Kivisto
                Reporter:
                rkivisto Ray Kivisto
              • Votes:
                2 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: