在Jenkins中更改Windows Shell(从Cygwin到Git Bash/msys) [英] Change Windows shell in Jenkins (from Cygwin to Git Bash/msys)

查看:177
本文介绍了在Jenkins中更改Windows Shell(从Cygwin到Git Bash/msys)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个装有Jenkins代理和Cygwin的Windows 7和Windows Server 2012从属服务器.我想避免使用Cygwin,而只使用Windows的Git随附的Git Bash外壳程序(我认为它称为msysgit).因此,我将C:\cygwin64重命名为C:\cygwin64.bak,从路径中删除了C:\cygwin64\bin,然后重新启动.

I have a Windows 7 and a Windows Server 2012 slave with the Jenkins agent and Cygwin already set up. I want to avoid Cygwin and just use the Git Bash shell that comes with Git for Windows (I think it's called msysgit). So I renamed C:\cygwin64 to C:\cygwin64.bak, removed C:\cygwin64\bin from the path, and rebooted.

Windows 2012框现在可以正常工作,运行(Unix)Shell脚本,$OSTYPE = msysuname = MSYS_NT-6.3(表明Git Bash shell正在运行).

The Windows 2012 box now works fine, (Unix) shell scripts run, $OSTYPE = msys, and uname = MSYS_NT-6.3 (indicating that the Git Bash shell is running).

Windows 7框将无法运行,并且会出现以下错误:

The Windows 7 box won't run anything, and gives the following error:

在工作区C:\ Users \ Jenkins \ workspace \ TEST的Win7上远程构建
[win7] $ sh -xe C:\ Users \ jenkins \ AppData \ Local \ Temp \ hudson5047939025129374618.sh
系统找不到指定的文件
致命:命令执行失败
java.io.IOException:无法运行程序"sh"(在目录"C:\ Users \ Jenkins \ workspace \ TEST"中):CreateProcess
错误= 2,系统找不到指定的文件.
     在java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)

Building remotely on win7 in workspace C:\Users\Jenkins\workspace\TEST
[win7] $ sh -xe C:\Users\jenkins\AppData\Local\Temp\hudson5047939025129374618.sh
The system cannot find the file specified
FATAL: command execution failed
java.io.IOException: Cannot run program "sh" (in directory "C:\Users\Jenkins\workspace\TEST"): CreateProcess
error=2, The system cannot find the file specified.
       at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)

所以我的问题是,如何配置Jenkins使用C:\Program Files\Git\bin\sh.exeC:\Program Files\Git\usr\bin\bash.exe运行Shell脚本?

So my question is, how do I configure Jenkins to use C:\Program Files\Git\bin\sh.exe, or C:\Program Files\Git\usr\bin\bash.exe to run shell scripts?

推荐答案

我已经解决了.詹金斯将只选择路径中的第一个sh.exe. Git Bash在C:\Program Files\Git\usr\bin处有一个exe,因此,如果将其添加到路径的开头,它将由Jenkins拾取.

I've worked it out. Jenkins will simply pick the first sh.exe in the path. Git Bash has an exe at C:\Program Files\Git\usr\bin, so if you add that to the beginning of your path it will be picked up by Jenkins.

进行此更改后,您必须重新启动从属与Jenkins的连接,否则路径将不会传播.如果您使用的是Java Web Start,则只需关闭Java窗口并重新启动它即可.

You have to restart your slave's connection with Jenkins after making this change, otherwise the Path won't propagate. If you're using the Java Web Start, just close the java window and relaunch it.

这篇关于在Jenkins中更改Windows Shell(从Cygwin到Git Bash/msys)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆