为什么 Jenkins 在使用 MSBuild 时忽略 %PATH% 变量?
我正在尝试使用 Jenkins 编译用 Delphi 创建的 MSBuild 项目。我已将 MSBuild 插件安装到 Jenkins 中并进行配置。我正在为我的构建作业选择特定配置。
我已经在 Jenkins 中设置了 Delphi 编译器所需的所有环境变量(对于 Delphi 类型,来自 rsvars.bat)。
该项目在命令行上编译得很好。如果我在命令行上执行此操作,MSBuild 会报告一个漂亮的大路径(正确的路径)作为它用来调用 Delphi 编译器的命令行的一部分。
然而,当我尝试将它与 Jenkins 一起使用时,结果完全不同:
C:\Program Files (x86)\Embarcadero\RAD Studio\8.0\bin\dcc32.exe -$D- -$L- -$Y- --no-config -B -Q -AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE -DRELEASE -K00400000 HTMLWriterTestApp.dpr
Embarcadero Delphi for Win32 compiler version 22.0
Copyright (c) 1983,2010 Embarcadero Technologies, Inc.
Noet 完全缺少路径,或者任何其他信息来查找编译器需要的内容。当我从命令行运行时,该信息就在那里。
谁能想到 Jenkins 无法获得正确的 PATH 信息的任何原因吗?
I am trying to use Jenkins to compile my MSBuild project created with Delphi. I have the MSBuild plugin installed into Jenkins and configured. I'm choosing the specific configuration for my build job.
I have set all the environmental variables in Jenkins that are required by the Delphi compiler (from rsvars.bat for you Delphi types.)
The project compiles just fine on the command line. If I do it on the command line, MSBuild reports a nice big fat PATH (the correct one) as part of the command line it uses to call the Delphi compiler.
However, when I try to use it with Jenkins, the result is quite different:
C:\Program Files (x86)\Embarcadero\RAD Studio\8.0\bin\dcc32.exe -$D- -$L- -$Y- --no-config -B -Q -AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE -DRELEASE -K00400000 HTMLWriterTestApp.dpr
Embarcadero Delphi for Win32 compiler version 22.0
Copyright (c) 1983,2010 Embarcadero Technologies, Inc.
Noet the complete lack of a path, or any other information about were to find what the compiler needs. This information is there when I run from the command line.
Can anyone think of any reason why Jenkins is failing to get the correct PATH information?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
根据您运行 Jenkins 的方式,它可能没有您习惯看到的完整路径行。例如,如果您将 Jenkins 作为 Windows 服务运行并填充了 USERS PATH 变量,则不一定会为 SYSTEM 用户填充它。在这种情况下,请将服务使用的登录帐户修改为您的帐户,而不是系统帐户。
Depending on how you run Jenkins, it may not have the full path line that you are used to seeing. For example, if you run Jenkins as a Windows Service and have your USERS PATH variable populated, you won't necessarily have it populated for the SYSTEM user. In this case, modify the Logon Account used by the Service to be your account, rather than a system one.
我让 Jenkins 在 Glassfish 内部的服务器上运行,在安装时作为本地系统帐户运行,通过使用这篇博文的派生,我能够通过在 Jenkins 的“系统配置”(Jenkins 环境注入器插件)中设置属性变量来使其工作。 (BDS、BDSCOMMONDIR、FrameworkDir、FrameworkSDKDir 等...)
然后 Delphi 选取适当路径的技巧是将命令行参数“Win32LibraryPath”发送到 MSBuild。确保在 Jenkins 中转义这个参数中的双引号,否则你会拔掉你的头发。
I have Jenkins running on a server inside Glassfish, running as the local system account, as it was installed, by using a derivation of this blog post, and I was able to get it to work by setting property variables in the "system configuration" (Jenkins Environment Injector Plug-in) in Jenkins. (BDS, BDSCOMMONDIR, FrameworkDir, FrameworkSDKDir etc...)
Then the trick for Delphi to pick up the appropriate path is to send the command line parameter "Win32LibraryPath" to MSBuild. Make sure to escape your double quotes in this parameter in Jenkins or else you will pull out your hair.
我让 Jenkins 作为 Windows 服务启动,即使我在系统用户的 PATH 变量中有 SVN\bin,它也找不到 SVN 命令。
该服务似乎仅使用启动时可用的环境变量。
因此,如果稍后您向 Windows 系统用户添加更多环境变量,它们将不可用于该服务。
您所要做的就是重新启动窗口服务,它将选择新的环境变量!
I had Jenkins started as windows service and it could not find an SVN command even if I had SVN\bin in my PATH variable for the System user.
It seems that the service uses only the environment variables available at start up time.
So if later on you add some more environment varibales to the Windows System user, they will not be available to the service.
All you have to do is restart the window service and it will pick the new environment variables !
任何带有 git pull/where git 命令的操作,如果不是从 Jenkins 执行,都是因为 Windows 环境变量中的路径问题。
PATH
。services.msc
重新启动从属服务。Anything with git pull/ where git commands, which are not executing from Jenkins is because of the path issue in the environmental variables in Windows.
PATH
in Environment variables.services.msc
.