Skip to content

Commit 9b4d721

Browse files
Refactor ssh executable search logic to prioritize system PATH check
1 parent 0b8101c commit 9b4d721

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2641,6 +2641,15 @@ public File getSSHExecutable() {
26412641
return sshexe;
26422642
}
26432643

2644+
// Check for ssh.exe on the system PATH (supports Microsoft OpenSSH and other alternate implementations)
2645+
String sshPath = getPathToExe("ssh");
2646+
if (sshPath != null) {
2647+
sshexe = new File(sshPath);
2648+
if (sshexe.exists()) {
2649+
return sshexe;
2650+
}
2651+
}
2652+
26442653
// Check Program Files
26452654
sshexe = getFileFromEnv("ProgramFiles", "\\Git\\bin\\ssh.exe");
26462655
if (sshexe != null && sshexe.exists()) {
@@ -2700,16 +2709,6 @@ public File getSSHExecutable() {
27002709
}
27012710
}
27022711

2703-
// Check for ssh.exe on the system PATH as last resort (supports Microsoft OpenSSH and other alternate
2704-
// implementations)
2705-
String sshPath = getPathToExe("ssh");
2706-
if (sshPath != null) {
2707-
sshexe = new File(sshPath);
2708-
if (sshexe.exists()) {
2709-
return sshexe;
2710-
}
2711-
}
2712-
27132712
throw new RuntimeException(
27142713
"ssh executable not found. The git plugin only supports official git client https://git-scm.com/download/win");
27152714
}

0 commit comments

Comments
 (0)