Skip to content

Commit ee01a7b

Browse files
Refactor ssh executable search logic to prioritize system PATH check
1 parent d6e4e3a commit ee01a7b

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
@@ -2626,6 +2626,15 @@ public File getSSHExecutable() {
26262626
return sshexe;
26272627
}
26282628

2629+
// Check for ssh.exe on the system PATH (supports Microsoft OpenSSH and other alternate implementations)
2630+
String sshPath = getPathToExe("ssh");
2631+
if (sshPath != null) {
2632+
sshexe = new File(sshPath);
2633+
if (sshexe.exists()) {
2634+
return sshexe;
2635+
}
2636+
}
2637+
26292638
// Check Program Files
26302639
sshexe = getFileFromEnv("ProgramFiles", "\\Git\\bin\\ssh.exe");
26312640
if (sshexe != null && sshexe.exists()) {
@@ -2685,16 +2694,6 @@ public File getSSHExecutable() {
26852694
}
26862695
}
26872696

2688-
// Check for ssh.exe on the system PATH as last resort (supports Microsoft OpenSSH and other alternate
2689-
// implementations)
2690-
String sshPath = getPathToExe("ssh");
2691-
if (sshPath != null) {
2692-
sshexe = new File(sshPath);
2693-
if (sshexe.exists()) {
2694-
return sshexe;
2695-
}
2696-
}
2697-
26982697
throw new RuntimeException(
26992698
"ssh executable not found. The git plugin only supports official git client https://git-scm.com/download/win");
27002699
}

0 commit comments

Comments
 (0)