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

Windows git-client plugin assumes ssh.exe is in same directory as git.exe

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      With the current version of the Git plugin, the code assumes to find SSH executable in a specific directory. By default this installation directory for Git on Windows is "C:\ProgramFiles\Git\bin\ssh.exe" (32-bit) or "C:\ProgramFiles (x86)\Git\bin\ssh.exe" (64-bit). I am referring to this method in the plugin's source code:

      https://github.com/jenkinsci/git-client-plugin/blob/master/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java#L1084

      If the Git client was installed into a custom directory, it's impossible to configure known SSH credentials. The plugin will show an error message. I understand that you want to ensure that the Git installation should be the official Git client. However in our environment we require that each Job must be able to specify specific versions of all tools so we must be able to support side by side installs of different versions Git.

      Would it be possible to extend the plugin to either determine the GIT & SSH executables in the PATH or allow the plugin to point to a custom GIT & SSH executable?

        Attachments

          Activity

          Hide
          markewaite Mark Waite added a comment - - edited

          Could you further clarify your use model?

          The code as implemented in git-client-plugin 1.6.2 first checks for git in the default location, then if it is not found there, it will check for an ssh in the same directory as the git executable.

          I think that algorithm would support your use model so long as you never install git in the default location. Choosing to never install git in the default location will further support your requirement that every job must explicitly declare its dependencies on the tools it uses.

          Is your use case that you want git available in the default location, and you want git in non-default locations, and you want the git executable to be selected first from the path, rather than the current technique which selects ssh first from the default git location, then failing that it selects ssh from the same directory that has the git binary?

          Or, is the root problem that the current code is not evaluating the PATH to find the executable?

          Show
          markewaite Mark Waite added a comment - - edited Could you further clarify your use model? The code as implemented in git-client-plugin 1.6.2 first checks for git in the default location, then if it is not found there, it will check for an ssh in the same directory as the git executable. I think that algorithm would support your use model so long as you never install git in the default location. Choosing to never install git in the default location will further support your requirement that every job must explicitly declare its dependencies on the tools it uses. Is your use case that you want git available in the default location, and you want git in non-default locations, and you want the git executable to be selected first from the path, rather than the current technique which selects ssh first from the default git location, then failing that it selects ssh from the same directory that has the git binary? Or, is the root problem that the current code is not evaluating the PATH to find the executable?
          Hide
          fstaats Frederick Staats added a comment -

          After looking at your note and the code it became clear what our issue was. There was a change in the git-client plugin behavior that made this hard to debug. On the server page https://jenkinsserver.com/configure page we configured Git to be accessed from cmd/git.exe (which worked with earlier versions of the Git plugin.) With the newer version of the plugin we found that we have to configure the path in bin/git.exe so it can find the bin/ssh.exe in the same directory. Given that the standard Git distribution includes both directories it should be made clear that the git-client plugin needs the path to bin/git.exe if you are using the ssh protocol.

          Show
          fstaats Frederick Staats added a comment - After looking at your note and the code it became clear what our issue was. There was a change in the git-client plugin behavior that made this hard to debug. On the server page https://jenkinsserver.com/configure page we configured Git to be accessed from cmd/git.exe (which worked with earlier versions of the Git plugin.) With the newer version of the plugin we found that we have to configure the path in bin/git.exe so it can find the bin/ssh.exe in the same directory. Given that the standard Git distribution includes both directories it should be made clear that the git-client plugin needs the path to bin/git.exe if you are using the ssh protocol.
          Hide
          markewaite Mark Waite added a comment -

          There were reports that using cmd/git.exe caused other problems, so my working assumption has been that bin/git.exe is the preferred msysgit implementation.

          I think that code may still need improvement, but I'm glad that your use model is covered.

          Show
          markewaite Mark Waite added a comment - There were reports that using cmd/git.exe caused other problems, so my working assumption has been that bin/git.exe is the preferred msysgit implementation. I think that code may still need improvement, but I'm glad that your use model is covered.
          Hide
          fstaats Frederick Staats added a comment -

          Thank you, I'm glad it is working for our use model too!

          Your assumption is not documented, it would be helpful to add a note on the Jenkins configuration page that on the Windows platform the use of bin/git.exe directory is required for SSH Git connections (and other reasons if there are any.).

          Show
          fstaats Frederick Staats added a comment - Thank you, I'm glad it is working for our use model too! Your assumption is not documented, it would be helpful to add a note on the Jenkins configuration page that on the Windows platform the use of bin/git.exe directory is required for SSH Git connections (and other reasons if there are any.).
          Hide
          markewaite Mark Waite added a comment -

          I would rather spend the time trying to remove the assumption than attempting to justify the details of the cases where cmd/git.exe does not behave as expected.

          http://blog.cgdecker.com/2011/02/git-clone-error-on-jenkinshudson-on.html describes a condition where the bin version of git was different than cmd version of git.

          http://stackoverflow.com/questions/7850395/jenkins-can-not-clone-git-repository-over-git-ssh-on-windows documents other differences between the two configurations (and more configurations).

          https://issues.jenkins-ci.org/browse/JENKINS-13007 is also probably related.

          Show
          markewaite Mark Waite added a comment - I would rather spend the time trying to remove the assumption than attempting to justify the details of the cases where cmd/git.exe does not behave as expected. http://blog.cgdecker.com/2011/02/git-clone-error-on-jenkinshudson-on.html describes a condition where the bin version of git was different than cmd version of git. http://stackoverflow.com/questions/7850395/jenkins-can-not-clone-git-repository-over-git-ssh-on-windows documents other differences between the two configurations (and more configurations). https://issues.jenkins-ci.org/browse/JENKINS-13007 is also probably related.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Mark Waite
          Path:
          src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java
          src/test/java/org/jenkinsci/plugins/gitclient/GitAPITestCase.java
          http://jenkins-ci.org/commit/git-client-plugin/9430af74220cc9a11dd5e523332c0f5006cbafdd
          Log:
          [Fixed JENKINS-21806] Improve ssh.exe finding on Windows with msysgit

          Adapt to msysgit installed in non-default locations, and to msysgit
          alternative configurations as allowed by the msysgit installer. The
          mssygit installer allows the user to choose to make no changes to the
          PATH, or to add the "cmd" directory to the PATH, or add the "bin"
          directory to the PATH.

          If the user chooses to make no changes to the PATH, then they
          configure their Jenkins git with the absolute path of the git
          executable.

          If the user chooses to add the "cmd" directory to the PATH, then they
          configure their Jenkins git with the executable as "git", "git.exe",
          or (with some msysgit versions) "git.cmd".

          If the user chooses to add the "bin" directory to the PATH, then they
          configure similarly to the "cmd" directory case.

          The plugin attempts to handle all those cases correctly.

          Special thanks to Thiago Zanetti for providing the original code for
          this fix.

          Compare: https://github.com/jenkinsci/git-client-plugin/compare/11e443933ff0...9430af74220c

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java src/test/java/org/jenkinsci/plugins/gitclient/GitAPITestCase.java http://jenkins-ci.org/commit/git-client-plugin/9430af74220cc9a11dd5e523332c0f5006cbafdd Log: [Fixed JENKINS-21806] Improve ssh.exe finding on Windows with msysgit Adapt to msysgit installed in non-default locations, and to msysgit alternative configurations as allowed by the msysgit installer. The mssygit installer allows the user to choose to make no changes to the PATH, or to add the "cmd" directory to the PATH, or add the "bin" directory to the PATH. If the user chooses to make no changes to the PATH, then they configure their Jenkins git with the absolute path of the git executable. If the user chooses to add the "cmd" directory to the PATH, then they configure their Jenkins git with the executable as "git", "git.exe", or (with some msysgit versions) "git.cmd". If the user chooses to add the "bin" directory to the PATH, then they configure similarly to the "cmd" directory case. The plugin attempts to handle all those cases correctly. Special thanks to Thiago Zanetti for providing the original code for this fix. Compare: https://github.com/jenkinsci/git-client-plugin/compare/11e443933ff0...9430af74220c
          Hide
          markewaite Mark Waite added a comment -

          Fix is first available in git-client-plugin 1.9.2, released 16 July 2014

          Show
          markewaite Mark Waite added a comment - Fix is first available in git-client-plugin 1.9.2, released 16 July 2014
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Mark Waite
          Path:
          src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java
          src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplTest.java
          src/test/java/org/jenkinsci/plugins/gitclient/GitAPITestCase.java
          http://jenkins-ci.org/commit/git-client-plugin/2a2c6d339dcda8556b267f8a3584a5dd762be387
          Log:
          Add mingw64 dir to ssh location guesser - windows git 2.8.0

          Implement ssh executable test in CliGitAPIImplTest, not applicable
          to JGit.

          May help JENKINS-30045, JENKINS-28943, JENKINS-25297, & JENKINS-21806

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplTest.java src/test/java/org/jenkinsci/plugins/gitclient/GitAPITestCase.java http://jenkins-ci.org/commit/git-client-plugin/2a2c6d339dcda8556b267f8a3584a5dd762be387 Log: Add mingw64 dir to ssh location guesser - windows git 2.8.0 Implement ssh executable test in CliGitAPIImplTest, not applicable to JGit. May help JENKINS-30045 , JENKINS-28943 , JENKINS-25297 , & JENKINS-21806

            People

            • Assignee:
              ndeloof Nicolas De Loof
              Reporter:
              fstaats Frederick Staats
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: