未验证 提交 be1e2bea 编写于 作者: R Rishabh Budhouliya 提交者: GitHub

[JENKINS-61711] Fix validateExecutable to allow Git plugin global config...

[JENKINS-61711] Fix validateExecutable to allow Git plugin global config correctly report git executable in PATH (#4653)

* Fix git not in path for Git plugin global config
Git Client Plugin global configuration allows addition of git implementations using GitTool
The field Path was not able to identify git executable. The fix involves changing prefix with
File.seperator instead of File.pathSeperator. This allows Jenkins to find the git exec at the
already existing path.

* Tests added to validate JENKINS-61711 fix

* Improve hamcrest comparison in FormValidationTest
Co-Authored-By: NMark Waite <mark.earl.waite@gmail.com>

* Import matchers for `not`
Co-authored-by: NMark Waite <mark.earl.waite@gmail.com>
上级 f5e94294
......@@ -65,7 +65,7 @@ class DOSToUnixPathHelper {
tokenizedPathBuilder.append(_dir.replace('\\', '/'));
if (checkPrefix(_dir + File.pathSeparator + exe, helper))
if (checkPrefix(_dir + File.separator + exe, helper))
return;
}
tokenizedPathBuilder.append('.');
......
package hudson.util;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
public class FormValidationTest {
@Rule
public JenkinsRule j = new JenkinsRule();
@Issue("JENKINS-61711")
@Test
public void testValidateExecutableWithFix() {
// Global Tool Configuration is able to find git executable in system environment at PATH.
FormValidation actual = FormValidation.validateExecutable("git");
assertThat(actual, is(FormValidation.ok()));
}
@Issue("JENKINS-61711")
@Test
public void testValidateExecutableWithoutFix() {
// Without JENKINS-61711 fix, Git installations under Global Tool Configuration is not able to find git
// executable at system PATH despite git exec existing at the path.
FormValidation actual = FormValidation.validateExecutable("git");
String failMessage = "There's no such executable git in PATH:";
assertThat(actual, not(is(FormValidation.error(failMessage))));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册