我可以使用 cygwin 编写 hudson 构建步骤的脚本吗?
我尝试执行以下命令:
#!C:\cygwin\bin\bash.exe
ls ${WORKSPACE}
但这没有找到 ls (即使它位于 Windows 路径上)。 有什么办法可以设置这个吗?
更新:换句话说,我希望能够设置一个使用 cygwin bash 而不是 Windows cmd 的构建步骤,例如 此页面向您展示如何使用Python。
I've tried executing the following:
#!C:\cygwin\bin\bash.exe
ls ${WORKSPACE}
But that doesn't find ls (even if it's on the windows path). Is there any way to set this up?
UPDATE: In other words, I want to be able to set up a build step that uses cygwin bash instead of windows cmd like this page shows you how to do with Python.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
因此,将
cygwin
的bin
目录放入PATH
中。如果您不知道如何操作(
控制面板
->系统
->高级
->环境变量
),请参阅:http://support.microsoft.com/kb/310519So put your
cygwin
'sbin
directory in yourPATH
.In case you don't know how to do it (
Control Panel
->System
->Advanced
->Environment Variables
), see: http://support.microsoft.com/kb/310519该 shell 脚本有两个错误:hash-bang 行应该是“#!/bin/bash”,并且 ${WORKSPACE} 不是 shell 变量。 Hudson 有一堆自己的变量,这些变量在您指定要运行的命令中扩展(即当您在 Web gui 中添加命令时)。
如果您想在 Cygwin 命令行上运行 Hudson 构建步骤,您需要弄清楚 Hudson 运行什么命令以及在哪个目录中。
要给出更具体的答案,您需要向我们展示您的项目是如何配置的以及您想要单独运行哪些步骤。
That shell-script has two errors: the hash-bang line should be "#!/bin/bash", and ${WORKSPACE} is not a shell-variable. Hudson has a bunch of variables of its own which are expanded in the commands you specify to be run (i.e. when you add commands in the web gui).
If you want to run Hudson build step on the Cygwin command line, you need to figure out what command Hudson runs and in which directory.
To give a more specific answer, you need to show us how your project is configured and what steps you want to run separately.
如果 cygwin 的 bin 文件夹位于您的路径中,则以下内容对我有用:
我发现 Hudson 不会拾取环境变量更改,除非您重新启动服务器。
Provided cygwin's bin folder is in your path, the following works for me:
I find Hudson does not pick up environment variable changes unless you restart the server.
您可能想尝试提供 ls 的完整路径
you might want to try to give a full path to ls
另一件似乎有效的事情是使用它:
但最好不必修改每个脚本的路径。
One other thing that seems to work is to use this:
But it would be nice not to have to modify the path for every script.
您是否考虑过 power shell? 尽管我很喜欢 cygwin,但它总是有点不稳定,powershell 是 Windows 上功能齐全的可靠 shell,另一个选择是 UNIX 的 Windows 服务 它为您提供 korn shell 或 c shell,虽然不如 bash 那么好,但它可以完成工作
Have you thought about power shell? as much as I like cygwin, it's always been a little flaky, powershell is a solid fully functional shell on windows, another option is Windows Services for UNIX it gives you korn shell or c shell not quite as nice as bash but it gets the job done
您需要将
--login
(又名-l
)选项传递给bash
,以便它将来源 Cygwin 的/etc/ profile
并正确设置PATH
变量。 这将导致当前目录更改为默认的“home”,但您可以在运行bash -l
CHERE_INVOKING 设置为1
> 如果您需要保留它,它将保留在当前目录中。You will need to pass the
--login
(aka-l
) option tobash
so that it will source Cygwin's/etc/profile
and set up thePATH
variable correctly. This will cause the current directory to get changed to the default "home" but you can set the environment variableCHERE_INVOKING
to1
before runningbash -l
and it will stay in the current directory if you need to preserve that.